Giter VIP home page Giter VIP logo

gmusic-playlist's Introduction

gmusic-playlist

playlist scripts for gmusic

Prerequisites

Before using the scripts, open up the preferences.py file and change the username.

When the scripts are run they will prompt for your password. If you use two factor authentication you will need to create and use an application password.

ExportLists.py

This script will export all playlists to a given directory as csv files. For the purpose of these scripts CSV stands for character seperated value. The default separator charator is ',' The separator character is configurable in the preferences file. Versions of the code previous to Aug 16 2015 used a '' separator character as the default. Most spreadsheet apps can open csv files.

The order in which the artist, album, and title information appears as well as the separating character between each piece of information is configured in the preference.py file. The default order and separator character will output song info as: "title","artist","album","songid"

The csv files can be re-imported using the ImportList.py script.

Command Line Usage: python ExportLists.py OutputDir

OutputDir is a directory you would like the playlists to be output to.

The export progress will be output to the console and to a log file. At the completion of the export a status of the overal makeup of the playlist will be output.

ImportList.py

This script will import a given csv file into google music as a playlist. The title of the playlist will be the name of the text file and each track will be matched to each line in the text file.

Command Line Usage: python ImportList.py ExamplePlaylist.csv

The progress of the playlist creation will be output to the console and to a log file. Tracks that could not be found are prefixed with !! and tracks that were found but may not be a good match are prefixed with -. One or more of the following will appear after a track with a low match: {A}{a}{T}{s} These markings indicate why the match was low, {A} means the artist didn't match, {T} means the title didn't match, {a} means the album didn't match, and {s} means it had a low result score. In addition to a log file, a csv file is created which contains all tracks found and their associated google music song id.

The csv file output from the ImportList.py script can be used to fix any song that didn't import correctly. Open the csv file, look for the songs without any song id and see if there is something that you can change in the track info to get google to find the song. Save the file and then re-run it through the ImportList.py script. Since the csv file will contain the song id's for songs it already found it won't need to look those up again and will just focus on finding the songs that don't have id's yet.

You can also look up the song you want via google music's web interface and get the song id by clicking share > get link. The song id is given in the link.

Playlist files

The format of each track in a playlist file can either be fuzzy or detailed info. Comments are also supported.

A fuzzy track is a track that has no separating characters and simply lists a song title, song title and author, or song author and title. See the ExamplePlaylist.csv file for a few examples of fuzzy tracks. Fuzzy tracks will only be matched to all access tracks. If you have a song in a playlist that isn't in all access, but is in your personal library you will need to use a detailed track.

A detailed track lists title,artist,and album information separated by the separator character and in the order defined in the preferences.py file. The songId is optional, and will be added by the scripts when outputting a csv file. See the ExamplePlaylist.csv file for a few examples of detailed track lists. The album can be left out if not required.

A comment in a playlist file follows the form of Ccomment where C is the separator character and comment is the comment. See the ExamplePlaylist.csv file.

see also

a javascript version for doing import / export directly within google music.

gmusic-playlist's People

Contributors

andrebask avatar bernikr avatar cubic3d avatar naatan avatar scowalt avatar sinemetu1 avatar soulfx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmusic-playlist's Issues

Add playlist position number to exported track details

Recieved an email requesting this feature. The email suggested the following code changes to implement the feature:

in exportlists.py

result_details = create_result_details(track, tnum+1)  # added the playlist track number

in common.py:

# creates result details from the given track
def create_result_details(track, playlistTrackNumber): # added the playlist track number
    result_details = {}
    for key, value in track.iteritems():
        result_details[key] = value
    result_details['songid'] = (track.get('storeId')
        if track.get('storeId') else track.get('id'))
    result_details['playlistTrackNumber'] = playlistTrackNumber # put playlistTrackNumber' in result_details
    return result_details

in preferences.py:

track_info_order = ['playlistTrackNumber','title','artist','album','genre','year','durationMillis','playCount','rating','songid']

create a gatherStats.py script

create a gatherStats.py script that will look over a given playlist and output interesting statistics. Make use of echo nest to augment and enhance any song meta data that google doesn't have to create some really interesting stats.

Error 'IndexError: list index out of range'

Hello i'm trying to import a playlist and i always get the following error:

Traceback (most recent call last):
File "ImportList.py", line 221, in
details = create_details(details_list)
File "C:\common.py", line 87, in create_details
details[track_info_order[pos]] = nfo.strip()
IndexError: list index out of range

ImportError: No module named gmusicapi

Hi, I just finished installing the gmusic dependency but still I can't manage to run Import.

pip install gmusicapi
Requirement already satisfied (use --upgrade to upgrade): gmusicapi in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): validictory!=0.9.2,>=0.8.0 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): decorator>=3.3.1 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): mutagen>=1.18 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): protobuf>=2.4.1 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): requests!=1.2.0,!=2.2.1,>=1.1.0 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil!=2.0,>=1.3 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): proboscis>=1.2.5.1 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): oauth2client>=1.1 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): mock>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): appdirs>=1.1.0 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): gpsoauth==0.0.3 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from protobuf>=2.4.1->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from python-dateutil!=2.0,>=1.3->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): httplib2>=0.9.1 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from oauth2client>=1.1->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from oauth2client>=1.1->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules>=0.0.5 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from oauth2client>=1.1->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): rsa>=3.1.4 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from oauth2client>=1.1->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): pbr>=0.11 in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from mock>=0.7.0->gmusicapi)
Requirement already satisfied (use --upgrade to upgrade): pycrypto in /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from gpsoauth==0.0.3->gmusicapi)

And then when I try to run it:

python ImportList.py ../spotify-export/amazingsongs2.txt 
Traceback (most recent call last):
  File "ImportList.py", line 8, in <module>
    from common import *
  File "/Users/marianolatorre/gmusic-playlist/common.py", line 5, in <module>
    from gmusicapi import Mobileclient
ImportError: No module named gmusicapi
python 
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Thanks!

Thumbs Up Export doesn't export every song

The current implementation of exporting the thumbs up playlist delivered in #18 doesn't export the thumbed up songs that are not part of the library.

It is possible to have a few of these songs by listening to radio stations and thumbing up tracks along the way, etc.

The current work-around is to use the google web client to select all thumbed up tracks and then add them to the library using the options menu drop down.

Running ImportList.py gives me an error

When running ImportList.py I get the following error. Any suggestions?

Login Successful.
Loading personal library... Traceback (most recent call last):
File "ImportList.py", line 194, in
library = load_personal_library()
File "/Users/basis/Downloads/gmusic-playlist-master/common.py", line 33, in load_personal_library
plib = api.get_all_songs()
File "/Library/Python/2.7/site-packages/gmusicapi/clients/mobileclient.py", line 133, in get_all_songs
tracks = self._get_all_items(mobileclient.ListTracks, incremental, include_deleted)
File "/Library/Python/2.7/site-packages/gmusicapi/clients/mobileclient.py", line 1044, in _get_all_items
return [s for chunk in generator for s in chunk]
File "/Library/Python/2.7/site-packages/gmusicapi/clients/mobileclient.py", line 1057, in _get_all_items_incremental
**kwargs)
File "/Library/Python/2.7/site-packages/gmusicapi/clients/shared.py", line 80, in _make_call
return protocol.perform(self.session, self.validate, _args, *_kwargs)
File "/Library/Python/2.7/site-packages/gmusicapi/protocol/shared.py", line 208, in perform
response = session.send(req_kwargs, cls.required_auth)
File "/Library/Python/2.7/site-packages/gmusicapi/session.py", line 86, in send
res = self._send_with_auth(req_kwargs, desired_auth, rsession)
File "/Library/Python/2.7/site-packages/gmusicapi/session.py", line 195, in _send_with_auth
return rsession.request(**req_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 335, in request
resp = self.send(prep, *_send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 438, in send
r = adapter.send(request, *_kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 292, in send
timeout=timeout
File "/Library/Python/2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 423, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/Library/Python/2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 234, in _get_conn
if conn and is_connection_dropped(conn):
File "/Library/Python/2.7/site-packages/requests/packages/urllib3/util.py", line 256, in is_connection_dropped
return select([sock], [], [], 0.0)[0]
TypeError: argument must be an int, or have a fileno() method.

ImportError: No module named decorator

tried to run ImportedList.py and get this:

Traceback (most recent call last):
  File "ImportList.py", line 8, in <module>
    from common import *
  File "/Users/toujames/Downloads/gmusic-playlist-master/common.py", line 5, in <module>
    from gmusicapi import Mobileclient
  File "/Library/Python/2.7/site-packages/gmusicapi-7.0.1_dev-py2.7.egg/gmusicapi/__init__.py", line 4, in <module>
    from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
  File "/Library/Python/2.7/site-packages/gmusicapi-7.0.1_dev-py2.7.egg/gmusicapi/clients/__init__.py", line 2, in <module>
    from gmusicapi.clients.webclient import Webclient
  File "/Library/Python/2.7/site-packages/gmusicapi-7.0.1_dev-py2.7.egg/gmusicapi/clients/webclient.py", line 7, in <module>
    from gmusicapi.clients.shared import _Base
  File "/Library/Python/2.7/site-packages/gmusicapi-7.0.1_dev-py2.7.egg/gmusicapi/clients/shared.py", line 4, in <module>
    from gmusicapi.utils import utils
  File "/Library/Python/2.7/site-packages/gmusicapi-7.0.1_dev-py2.7.egg/gmusicapi/utils/utils.py", line 20, in <module>
    from decorator import decorator
ImportError: No module named decorator

Playlists over 1k won't import all tracks

Google doesn't allow more than 1k songs in a playlist. When importing a playlist with more than 1k songs, when the 1001 song is reached create a new playlist with the same name as the previous playlist but with Part 2 append and place the remaining songs in that playlist.

Feature Idea: Reporting of Playlist Duplicates

As a user, I would like to have the report include details within each playlist, of duplicate artist and track titles. It's currently very easy to inadvertently add a duplicates on Google Music.

Python 3 related errors and what I changed

Thanks for the awesome scripts. I tried using Python 3 without fully reading your requirements and got the script to work after some tweaking. However, I couldn't get my Spotify playlists into a csv format that gmusic-playlist seemed to like so I kept getting empty playlists on google music. I eventually found "portify.js" which worked for me, but playing around with your script help me learn some more about Python, so thanks again!

Anyway, in case anyone else tries to get this working with Python 3, here's what I did:

Traceback (most recent call last):
File "ImportList.py", line 171, in
input_filename = sys.argv[1].decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'

Removed .decode('utf-8') (not needed in Python 3)

Traceback (most recent call last):
File "ImportList.py", line 177, in
output_filename += u'_' + unicode(datetime.datetime.now().strftime(
NameError: name 'unicode' is not defined

Removed all of the unicode() instances (same reason as above)

Traceback (most recent call last):
File "ImportList.py", line 188, in
plog('Reading playlist... ')
File "[my directory]\gmusic\common.py", line 63, in plog
log(message, nl = False)
File "[my directory]\gmusic\common.py", line 52, in log
sys.stdout.write(message.encode(sys.stdout.encoding, errors='replace'))
TypeError: write() argument must be str, not bytes

Changed
sys.stdout.write(message.encode(sys.stdout.encoding, errors='replace'))
to

sys.stdout.write(message)

File "ImportList.py", line 318, in
u'/'+len(current_songs)+' songs')
TypeError: Can't convert 'int' object to str implicitly

make sure you wrape any len() code that's being combined with a string with the str() code.

Suggestion: Fall-back and remove "(...)" from name when searching

I used your ImportList.py script to import songs from Rdio into Google Play Music All Access, after using my own script to export from Rdio to CSV. It worked, great work! I had an issue with a few songs not being recognised because they had "(Radio Edit)" in the name on Rdio but not on Google Play. Would it be possible to edit the script to remove "(Radio Edit)" from the title when searching? I'd try to modify it my self but I don't know any Python :P

Implement proper support for escaped CSV values

Playlists in which track information contains the separator value are not properly escaped.

Change reading and writing logic to use python's built in csv module for reading and writing values so that we get properly escaped values.

Oddly non-functioning

I've had little success getting this to work and it ultimately came down to:

common.py lines 116-120 'details[artist..album..etc] = None' // record nothing for the track
and
ImportList.py lines 231-233 'skip track if details[artist..album..etc] = None' // check for the above nerf

It was an odd alignment amounting in zero functionality, at least that's what I've found. What's the go? I assume I'm missing something but if not, thought it worth a mention ...

create an ExportList.py script

create an ExportList.py script that will allow existing playlists to be exported to a text file.

command line usage: python ExportList.py ExistingPlaylist.txt
gui (windows) usage: drag and drop a txt file with a name matching an existing playlist onto ExportList.py

The file name of the text file is an existing playlist and each line of the text file follows the format of "artist ~ title". Where the '~' character should be a character that effectively separates the artist and title of the track, but doesn't interfere with ImportList.py's ability to re-import the list.

If the filename given doesn't match any existing playlist, log the issue and exit. If a file matching the given filename already exists do not overwrite the existing playlist, open a new file with a datetime stamp appended to the filename and write the playlist to that file.

SSLError

I got all my Spotify playlists into a nice CSV and was trying to loop through them and import them into Play Music. I get the following error:

Reading playlist... done. 5 lines loaded.
Logging into google music...
****[email protected]'s password:
Traceback (most recent call last):
File "/Users/__/Downloads/gmusic-playlist-master/ImportList.py", line 193, in
api = open_api()
File "/Users/_
_/Downloads/gmusic-playlist-master/common.py", line 162, in open_api
if not api.login(username, password, Mobileclient.FROM_MAC_ADDRESS):
File "/usr/local/anaconda/lib/python2.7/site-packages/gmusicapi/clients/mobileclient.py", line 64, in login
if not self.session.login(email, password, android_id):
File "/usr/local/anaconda/lib/python2.7/site-packages/gmusicapi/session.py", line 170, in login
res = gpsoauth.perform_master_login(email, password, android_id)
File "/usr/local/anaconda/lib/python2.7/site-packages/gpsoauth/init.py", line 66, in perform_master_login
return _perform_auth_request(data)
File "/usr/local/anaconda/lib/python2.7/site-packages/gpsoauth/init.py", line 22, in _perform_auth_request
headers={'User-Agent': useragent})
File "/usr/local/anaconda/lib/python2.7/site-packages/requests/api.py", line 107, in post
return request('post', url, data=data, json=json, *_kwargs)
File "/usr/local/anaconda/lib/python2.7/site-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/local/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/anaconda/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/local/anaconda/lib/python2.7/site-packages/requests/adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

Any ideas why my SSL library isn't working? I updated pyOpenSSL...

I18n bug during import

I noticed very strange issue while I imported tracks

Annotation 2020-03-09 224354

Some of the English names were transliterated into Cyrillic. Then I start digging and realized that the reason was that target account had Russian locale, when I changed it to English and re-imported it again all went fine.

Very weird bug.

create ImportCsv.py script

create a script that can take in a csv file where each record contains track information on artist, title, and album. when importing the file, perform a lookup for the album and continue the search from there. this will provide a more exact search than the ImportList.py script.

Creates playlist, but doesn't actually import any files

I get output like that listed below. However, when I go to Google Music, the playlist itself is empty. I am using an app password (https://support.google.com/accounts/answer/185833?hl=en) if that makes any difference.

Reading playlist... done. 87 lines loaded.
Logging into google music...
[account]@gmail.com's password: 
Login Successful.
Loading personal library... done. 6455 personal tracks loaded.
===============================================================
Searching for songs from: Succubus Club Rotation Spotify
===============================================================
!! Love Like Blood\Killing Joke\Laugh? I Nearly Bought One!
!! At Dawn They Sleep\Anders Manga\Blood Lush
!! Day Of The Lords - 2007 Remastered Version\Joy Division\Unknown Pleasures [Collector's Edition]
!! Warsaw - Original\Hernan Cattaneo, John Tonks\Warsaw
!! Kephalopher\Bleiburg, Arcana Obscura\The Grey Years
!! Let´s Drop Bombs\Haujobb\New World March
===============================================================
Adding 81 found songs to: Succubus Club Rotation Spotify
===============================================================
 + Succubus Club Rotation Spotify - 81/81 songs
===============================================================
   81/87 tracks imported
 ! 6.89655172414% of tracks could not be matched
 - 0.0% of tracks had low match scores
  {T} 0 low matches were due to a song title mismatch
  {A} 0 low matches were due to song artist mismatch
  {D} 0 duplicates were found and skipped
 + 93.1034482759% of tracks had high match scores

top 3 genres: []
top 3 artists: []
top 3 years: []
playlist playback ratio: 0.0

search time: 1.60347104073

httplib.IncompleteRead: IncompleteRead(0 bytes read)

My sync script has suddenly stopped working. Not sure if Google have changed something, Debian have pushed out some flakey Python update, or what... I have tried loads of things so far, including a total Python reinstall (which is quite hairy when Debian needs python itself to manage packages).

Logging into google music...
[email protected]'s password:
Traceback (most recent call last):
File "/root/gmusic-playlist/ExportLists.py", line 17, in
api = open_api()
File "/root/gmusic-playlist/common.py", line 111, in open_api
if not api.login(username, password):
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/clients/mobileclient.py", line 39, in login
if not self.session.login(email, password):
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/session.py", line 147, in login
success = super(Mobileclient, self).login(email, password, _args, _kwargs)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/session.py", line 122, in login
webclient.Init.perform(self, True)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/protocol/shared.py", line 208, in perform
response = session.send(req_kwargs, cls.required_auth)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/session.py", line 86, in send
res = self._send_with_auth(req_kwargs, desired_auth, rsession)
File "/usr/local/lib/python2.7/dist-packages/gmusicapi/session.py", line 142, in _send_with_auth
return rsession.request(
_req_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 605, in send
r.content
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/response.py", line 304, in stream
for line in self.read_chunked(amt):
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/response.py", line 411, in read_chunked
raise httplib.IncompleteRead(''.join(line))
httplib.IncompleteRead: IncompleteRead(0 bytes read)

Exporting playlists with forward slashes in them results in an error

For example, I had a playlist named "Late nights/early mornings". Here's the error I got:

Traceback (most recent call last):
  File "ExportLists.py", line 99, in <module>
    playlist_handler(playlist_name, playlist_description, playlist_tracks)
  File "ExportLists.py", line 26, in playlist_handler
    open_log(os.path.join(output_dir,playlist_name+u'.log'))
  File "/Users/nf/workspace/gmusic-playlist/common.py", line 40, in open_log
    logfile = codecs.open(filename, encoding='utf-8', mode='w', buffering=1)
  File "/Users/nf/.virtualenvs/gmusic/lib/python2.7/codecs.py", line 884, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: u'output/Late nights/early mornings.log'

The slash is a reserved character for directories, so the entire export fails. A reasonable workaround would be to swap slashes in names for dashes.

Error with python 2.7.11?

Here's what I'm getting when I try to run ImportList.py:

$ python ImportList.py playlist_copy.csv
Traceback (most recent call last):
  File "ImportList.py", line 8, in <module>
    from common import *
  File "/Users/jordynbonds/Downloads/gmusic-playlist-master/common.py", line 5, in <module>
    from gmusicapi import Mobileclient
  File "/usr/local/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/__init__.py", line 4, in <module>
    from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
  File "/usr/local/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/__init__.py", line 1, in <module>
    from gmusicapi.clients.webclient import Webclient
  File "/usr/local/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/webclient.py", line 6, in <module>
    from gmusicapi.clients.shared import _Base
  File "/usr/local/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/shared.py", line 3, in <module>
    from gmusicapi.utils import utils
  File "/usr/local/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/utils/utils.py", line 19, in <module>
    from google.protobuf.descriptor import FieldDescriptor
  File "/usr/local/lib/python2.7/site-packages/protobuf-3.0.0b1.post2-py2.7.egg/google/__init__.py", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 21, in <module>
    import io
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

Thanks for your help!

ImportError: No module named Crypto.PublicKey

Steps I have followed:

  1. On my Windows 7 laptop I installed Python 2.7.11.
  2. Downloaded the gmusicplayer zip and extracted it into my downloads folder.
  3. Downloaded the gmusicapi zip, extracted it into my downloads folder, then copied the extracted folder to the gmusicapi folder. (I am a newbie and thought gmusicapi files had to be in the same folder as gmusicplayer to be recognized. Later I learned that I needed to install gmusicapi first)
  4. Installed gmusic api with the following command via a windows command prompt (start-->run-->cmd).
    C:\Users\rlopin\Downloads\gmusic-playlist-master\gmusic-playlist-master>c:\python27\python.exe setup.py install
  5. Updated the preferences.py file to include my google user name and changed the delimiter to the pipe character to match the delimiter of the playlist file I created prior to step 1.
  6. Ran the ImportList.py:
    C:\Users\rlopin\Downloads\gmusic-playlist-master\gmusic-playlist-master>c:\python27\python.exe ImportList.py "Rob's Dance Playlist.txt"

This is the resulting error:
ImportError: No module named Crypto.PublicKey

Where do I find this module and how to I install it?

No module named syslog

I have an issue similar to this
It looks like syslog is specific to Linux only. It would be better to make script more cross-platform.

Playlist created, no songs

I am having an odd problem - things seem to work ok, the log shows songs being match and a playlist being created.

When I check in GM when it is complete, there is indeed a playlist created, but the contents are empty.

I am using a 2FA account, with a generated password. Logs + CSV are in the attached zip, is there somewhere else I can look for error logs?

playlist+log.zip

match csv format of javascript version

would like to match input and output format that javascript version uses since it offers more functionality and provides a way for the two versions to interoperate

acceptance criteria

  1. verify import reads in csv file output from javascript version
  2. verify export outputs a single csv file that can be read by the javascript version

Duplicate matches with detailed tracks

I found out that I got a handful of duplicate matches when uploading my local playlists with ImportList.py, but they were not really duplicates. It happened with titles in the same playlist which contained a word that existed in another title.

For example:

Track1 title: "Test"
Track2 title: "Test for test"

One of them will be marked as duplicate even when they are explicitly different.

In ImportList.py -> search_for_track(details), around line 97, when it´s doing the detailed search it does a few String inside String comparisons. Im not sure why its needed there, and my Python knowledge is inexistent, but I changed them to a normal == String comparison and all my >50 playlist are working fine.

I dont know if this is the correct solution though since I havent really though of all the possible side effects, but I´ve already learned more Python that I ever wanted!

Regards

Feature Request: Allow/Disallow Explicit songs from preferences

Hello,
I am exporting playlists that are going to be played over a stream and it would be helpful to have it setup so that when I am importing playlists, the explicit songs as marked by google music, won't be added because of the explicit. Is there a way to check this in the ImportList.py or add a setting in preferences.py?

Importing "succeeds" to no effect

I get output as below, playlists are created in my account, but no tracks are added to any of them. Have you seen this before?

Login Successful.
Loading personal library... done. 1488 personal tracks loaded.
===============================================================
Searching for songs from: 12-1-2015collection-1
===============================================================
===============================================================
Adding 15000 found songs to: 12-1-2015collection-1
===============================================================
 + 12-1-2015collection-1 Part 1 - 1000/1000 songs
 + 12-1-2015collection-1 Part 2 - 1000/1000 songs
 + 12-1-2015collection-1 Part 3 - 1000/1000 songs
 + 12-1-2015collection-1 Part 4 - 1000/1000 songs
 + 12-1-2015collection-1 Part 5 - 1000/1000 songs
 + 12-1-2015collection-1 Part 6 - 1000/1000 songs
 + 12-1-2015collection-1 Part 7 - 1000/1000 songs
 + 12-1-2015collection-1 Part 8 - 1000/1000 songs
 + 12-1-2015collection-1 Part 9 - 1000/1000 songs
 + 12-1-2015collection-1 Part 10 - 1000/1000 songs
 + 12-1-2015collection-1 Part 11 - 1000/1000 songs
 + 12-1-2015collection-1 Part 12 - 1000/1000 songs
 + 12-1-2015collection-1 Part 13 - 1000/1000 songs
 + 12-1-2015collection-1 Part 14 - 1000/1000 songs
 + 12-1-2015collection-1 Part 15 - 1000/1000 songs
===============================================================
   15000/15000 tracks imported
 ! 0.0% of tracks could not be matched
 - 0.0% of tracks had low match scores
  {T} 0 low matches were due to a song title mismatch
  {A} 0 low matches were due to song artist mismatch
 + 100.0% of tracks had high match scores

top 3 genres: []
top 3 artists: []
top 3 years: []
playlist playback ratio: 0.0

search time: 0.727869987488

ImportPlaylist creates playlist with only 1 song

When I run ImportPlaylist, a new Google Music playlist is created with only 1 song in it, even though the log file says that 4 songs were matched.

I've tried this with both the recommended and head versions of the Google Play Music API.

I've also tried this with a CSV file created by ExportPlaylist, with the same result.

test1_20160123180542.log.zip

use search algorithm of javascript version

would like to modify song matching code to use logic of javascript so that it doesn't take as long to import songs, more songs are matched, and matches are more accurate.

acceptance criteria

  1. verify songs import quicker
    given a list of songs that previously didn't match very well...
  2. verify more songs are matched
  3. verify songs are more accurately matched

development notes

  • javascript is quicker to search because it performs each song search asynchronously

Newbie help on "ImportError: No module named gmusicapi"

Hi,

I am a newbie at Python and I don't know a lot. I am using this guide (https://www.reddit.com/r/spotify/comments/35dgmj/instructions_to_import_music_from_spotify_into/) to transfer my music playlist from Spotify to Google Music. I am at the last step and I am getting this problem.

Angads-MacBook-Pro:gmusic-playlist-master Angad$ python ImportList.py ~/Desktop/Spotify.txt
Traceback (most recent call last):
File "ImportList.py", line 8, in <module> from common import *
File "/Users/Angad/Downloads/gmusic-playlist-master/common.py", line 5, in <module> from gmusicapi import Mobileclient
ImportError: No module named gmusicapi

I know that you have talked about this in another thread, but I could not understand an easy solution to this.

I hope that you can help me with this. Otherwise I am going to have to gruel though transferring my playlist song by song. 😁

404 Client Error: Not Found

Hi,

Just trying to get some music imported and I am getting the following issue:

Traceback (most recent call last):
  File "ImportList.py", line 194, in <module>
    api = open_api()
  File "/home/squawk/gmusic-playlist-master/common.py", line 151, in open_api
    dlog(u'Available track details: '+str(get_google_track_details()))
  File "/home/squawk/gmusic-playlist-master/common.py", line 63, in get_google_track_details
    results = api.search_all_access(sample_song,max_results=1).get('song_hits')
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-7.0.1.dev0-py2.7.egg/gmusicapi/clients/mobileclient.py", line 940, in search_all_access
    res = self._make_call(mobileclient.Search, query, max_results)
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-7.0.1.dev0-py2.7.egg/gmusicapi/clients/shared.py", line 80, in _make_call
    return protocol.perform(self.session, self.validate, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-7.0.1.dev0-py2.7.egg/gmusicapi/protocol/shared.py", line 225, in perform
    raise CallFailure(err_msg, call_name)
gmusicapi.exceptions.CallFailure: Search: 404 Client Error: Not Found for url: https://mclients.googleapis.com/sj/v1.11/query?q=one+u2&max-results=1
(requests kwargs: {'url': 'https://mclients.googleapis.com/sj/v1.11/query', 'headers': {'Authorization': '<omitted>'}, 'params': {'q': 'one u2', 'max-results': 1}, 'method': 'GET'})
(response was: '{\n "error": {\n  "errors": [\n   {\n    "domain": "global",\n    "reason": "notFound",\n    "message": "Not Found"\n   }\n  ],\n  "code": 404,\n  "message": "Not Found"\n }\n}\n')

Dependency issue?

Hi,

I installed manually the gmusicapi depedency as required by the readme (using he correct commit) but can t make the module work.

Below is my error message:

$ python ExportLists.py ../export/
Logging into google music...
[email protected]'s password: 
Login Successful.
Traceback (most recent call last):
  File "ExportLists.py", line 17, in <module>
    api = open_api()
  File "/Users/XXX/Downloads/gmusic-playlist-master/common.py", line 151, in open_api
    dlog(u'Available track details: '+str(get_google_track_details()))
  File "/Users/XXX/Downloads/gmusic-playlist-master/common.py", line 63, in get_google_track_details
    results = api.search_all_access(sample_song,max_results=1).get('song_hits')
  File "/Users/XXX/anaconda/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/mobileclient.py", line 938, in search_all_access
    res = self._make_call(mobileclient.Search, query, max_results)
  File "/Users/XXX/anaconda/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/shared.py", line 80, in _make_call
    return protocol.perform(self.session, self.validate, *args, **kwargs)
  File "/Users/XXX/anaconda/lib/python2.7/site-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/protocol/shared.py", line 225, in perform
    raise CallFailure(err_msg, call_name)
gmusicapi.exceptions.CallFailure: Search: 404 Client Error: Not Found for url: https://mclients.googleapis.com/sj/v1.11/query?q=one+u2&max-results=1
(requests kwargs: {'url': 'https://mclients.googleapis.com/sj/v1.11/query', 'headers': {'Authorization': '<omitted>'}, 'params': {'q': 'one u2', 'max-results': 1}, 'method': 'GET'})
(response was: '{\n "error": {\n  "errors": [\n   {\n    "domain": "global",\n    "reason": "notFound",\n    "message": "Not Found"\n   }\n  ],\n  "code": 404,\n  "message": "Not Found"\n }\n}\n')

Any idea?

Kind regards,
Michael

SyntaxError: invalid syntax

Hi,

I'm trying to to use the script with this command:
python ExportLists.py playlists

And i've this error:

Traceback
(most recent call last):
File "ExportLists.py", line 4, in ?
from common import *
File "/home/gle/gmusic-playlist-master/gmusic-playlist-master/common.py", line 92
if track.get('storeId') else track.get('id'))
^
SyntaxError: invalid syntax

Any ideas ?

Also, can I export all my music ? and not just all my playlists ?

Thanks in advance !

ImportError: Cannot open shared object file: No such file or directory

tried to run "sudo python ImportList.py ~/Downloads/spotify-music.txt" and get this:

Traceback (most recent call last):
  File "ImportList.py", line 8, in <module>
    from common import *
  File "/home/edson/Downloads/gmusic-playlist-master/common.py", line 9, in <module>
    from gmusicapi import __version__ as gmusicapi_version
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-10.1.1rc1-py2.7.egg/gmusicapi/__init__.py", line 4, in <module>
    from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-10.1.1rc1-py2.7.egg/gmusicapi/clients/__init__.py", line 4, in <module>
    from gmusicapi.clients.webclient import Webclient
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-10.1.1rc1-py2.7.egg/gmusicapi/clients/webclient.py", line 16, in <module>
    from gmusicapi.clients.shared import _Base
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-10.1.1rc1-py2.7.egg/gmusicapi/clients/shared.py", line 7, in <module>
    from gmusicapi.utils import utils
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-10.1.1rc1-py2.7.egg/gmusicapi/utils/utils.py", line 24, in <module>
    from google.protobuf.descriptor import FieldDescriptor
  File "/usr/local/lib/python2.7/dist-packages/protobuf-3.2.0rc1-py2.7.egg/google/protobuf/descriptor.py", line 46, in <module>
    from google.protobuf.pyext import _message
ImportError: libprotobuf.so.12: cannot open shared object file: No such file or directory

requests.exceptions.SSLError

Hi,

When I execute the script, I enter my password and then I've got an SSl error:

python ExportLists.py playlists

Logging into google music...
[email protected]'s password:
Traceback (most recent call last):
File "ExportLists.py", line 17, in
api = open_api()
File "/home/vmadmin/dev/gmusic-playlist-master/gmusic-playlist-master/common.py", line 162, in open_api
if not api.login(username, password, Mobileclient.FROM_MAC_ADDRESS):
File "/usr/local/lib/python2.7/dist-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/clients/mobileclient.py", line 64, in login
if not self.session.login(email, password, android_id):
File "/usr/local/lib/python2.7/dist-packages/gmusicapi-7.0.0.dev0-py2.7.egg/gmusicapi/session.py", line 170, in login
res = gpsoauth.perform_master_login(email, password, android_id)
File "/usr/local/lib/python2.7/dist-packages/gpsoauth-0.0.4-py2.7.egg/gpsoauth/init.py", line 66, in perform_master_login
return _perform_auth_request(data)
File "/usr/local/lib/python2.7/dist-packages/gpsoauth-0.0.4-py2.7.egg/gpsoauth/init.py", line 22, in _perform_auth_request
headers={'User-Agent': useragent})
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 107, in post
return request('post', url, data=data, json=json, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 53, in request
return session.request(method=method, url=url, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 447, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)

No module named google.protobuf.descriptor

Hi, when i run ExportLists.py, I have this error

# python ImportList.py Playlist.csv

Traceback (most recent call last):
  File "ImportList.py", line 8, in <module>
    from common import *
  File "/volume1/public/gmusic-playlist/common.py", line 5, in <module>
    from gmusicapi import Mobileclient
  File "/volume1/public/gmusic-playlist/gmusicapi/__init__.py", line 4, in <module>
    from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
  File "/volume1/public/gmusic-playlist/gmusicapi/clients/__init__.py", line 1, in <mod
    from gmusicapi.clients.webclient import Webclient
  File "/volume1/public/gmusic-playlist/gmusicapi/clients/webclient.py", line 6, in <mo
    from gmusicapi.clients.shared import _Base
  File "/volume1/public/gmusic-playlist/gmusicapi/clients/shared.py", line 3, in <modul
    from gmusicapi.utils import utils
  File "/volume1/public/gmusic-playlist/gmusicapi/utils/utils.py", line 19, in <module>
    from google.protobuf.descriptor import FieldDescriptor
ImportError: No module named google.protobuf.descriptor

I have tried on Synolgy with pyton 2.7.11 and on Windows with pyton 2.7.10 and I have the same error.
It is a missing package ?

search personal library when unable to locate a match in all access

When all access cannot match a track, perform a search in the personal library for the track.

The search should search the library using a fuzzy search algorithm that can query based on title, title artist, or artist title and return the closest matching song and it's match rating. A threshold will need to be determined for which no results are returned if the match rating is too low.

Error importing a playlist

Hi,

When using import.py, I get an error:

Traceback (most recent call last):
File "/Volumes/../Downloads/gmusic-playlist-master 3/ImportList.py", line 249, in
if not search_result and re.search(match_string,details['title']):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 142, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or buffer

Any idea what is going wrong and how can I resolve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.