tyris / m3ugooglemusicsync Goto Github PK
View Code? Open in Web Editor NEWA python class to sync m3u playlists to Google Music.
A python class to sync m3u playlists to Google Music.
Call to os.path.abspath should be done from the same path as the playlist (rather than the path the sync is called from).
Trying to add a playlist with :
ms.sync_playlist("/var/lib/mpd/playlists/s13.m3u")
and the today head of the git repo for unofficial google music api, I get the following backtrace :
Traceback (most recent call last):
File "example.py", line 7, in <module>
ms.sync_playlist("/var/lib/mpd/playlists/s13.m3u")
File "/home/clabaut/contrib/m3uGoogleMusicSync/musicsync.py", line 101, in sync_playlist
self.playlists['user'][title] = [self.wc.create_playlist(title)]
AttributeError: 'Webclient' object has no attribute 'create_playlist'
When uploading files with missing ID3 data, it throws a index errors for the missing data.
Suitable defaults need to be determined to match these files properly with what is on googles servers.
Need to investigate how Google Music stores such files (that are only identified by a filename).
script:
from musicsync import MusicSync
import os
import sys
ms = MusicSync("[email protected]","secretpassword")
# I use two-factor auth, so the password in my case is a generated "one-time" password
for dirpath, dirnames, filenames in os.walk('/usb/smb/Audio/Playlists'):
print "Dir ", dirpath
for filename in filenames:
print "File ", filename
if filename.endswith('.m3u'):
print "Uploading ", dirpath.rstrip('/')+"/"+filename
ms.sync_playlist( os.path.join(dirpath, filename))
log:
Logged in as [email protected]
Fetching playlists from Google...
Got 3 playlists.
Dir /usb/smb/Audio/Playlists
File ElectronicEighties.m3u
Uploading /usb/smb/Audio/Playlists/ElectronicEighties.m3u
Synching playlist: /usb/smb/Audio/Playlists/ElectronicEighties.m3u
didn't exist... creating...
0 songs already in Google Music playlist
Failed on: #EXTM3U
Failed on: ..\path\to\file<snip>
0 songs in local playlist
---
0 songs unmodified
0 songs added
0 songs failed
0 songs removed
File 4StarPlus_Rock_And_Metal.m3u
Uploading /usb/smb/Audio/Playlists/4StarPlus_Rock_And_Metal.m3u
Synching playlist: /usb/smb/Audio/Playlists/4StarPlus_Rock_And_Metal.m3u
didn't exist... creating...
0 songs already in Google Music playlist
Failed on: ..\path\to\file<snip>
0 songs in local playlist
---
0 songs unmodified
0 songs added
0 songs failed
0 songs removed
File 5Star.m3u
Uploading /usb/smb/Audio/Playlists/5Star.m3u
Synching playlist: /usb/smb/Audio/Playlists/5Star.m3u
didn't exist... creating...
0 songs already in Google Music playlist
Failed on: ..\path\to\file<snip>
simon-weber released version 1.0.0 of gmusic api which includes "big backwards-incompatible change in it" (simon-weber/gmusicapi#93 (comment))
All in all the "from gmusicapi.api import Api" syntax has been deprecated and now it requires either the Webclient or Musicmanager import (in m3uGoogleMusicSync I reckon it will be the latter but I don't know much about all this, I'm quite new in the world of python...) as it is explained here : https://unofficial-google-music-api.readthedocs.org/en/latest/usage.html#quickstart
Whatever I do, I cannot get these to match. The music is there at Google end, but it shows no match and tries to upload (the upload intentionally fails, as I have the retry count set to 0, I don't want dupes).
Tried allsorts, even copying the tags from Google Music web interface into MP3Tag and recreating the ID3 info. It's not having it, totally refusing to match these files. If you need any other details, please let me know.
Turned on logging:
Uploading /usb/smb/Audio/Playlists/4StarPlus_Rock_And_Metal.m3u
Synching playlist: /usb/smb/Audio/Playlists/4StarPlus_Rock_And_Metal.m3u
483 songs already in Google Music playlist
486 songs in local playlist
Adding: 05 smash it up.m4a
[{u'comment': u'', u'rating': 0, u'lastPlayed': 1309567095069875L, u'disc': 0, u'matchedId': u'T3hmvfcaysgxgbgtc2sjr2schwi', u'composer': u'Algy Ward/Captain Sensible/Dave Vanian/Rat Scabies', u'year': 1994, u'id': u'd8ddf9f0-bad2-3f3f-89aa-bcad64b052c5', u'subjectToCuration': False, u'album': u'Sessions of the Damned', u'title': u'Smash It Up', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh5.googleusercontent.com/512zAzfTHd527dV6FnJaDp3qIlSBW4K10bsY55sZen4H4XMhQpbFmgQ2tm4=s130-c-e100', u'type': 2, u'titleNorm': u'smash it up', u'track': 15, u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997468462075L, u'name': u'Smash It Up', u'albumNorm': u'sessions of the damned', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 242346, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309568640825704L, u'disc': 0, u'matchedId': u'Tx7lmkil3jenzsxw6vl67yluoli', u'composer': u'', u'year': 1979, u'id': u'25bee812-dbf6-3bcb-b6a6-5ef47ccc1ef0', u'subjectToCuration': False, u'album': u'The Best Of The Damned', u'title': u'smash it up', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh4.googleusercontent.com/WI2J5Vj0uZquE4NcPdQfOAnIT5klA8FZCdPTsZpShwFm0cXZz6V6n7IT12JW=s130-c-e100', u'type': 2, u'titleNorm': u'smash it up', u'track': 5, u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Punk', u'playCount': 0, u'creationDate': 1308997468462075L, u'name': u'smash it up', u'albumNorm': u'the best of the damned', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 173011, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309563691570519L, u'disc': 0, u'matchedId': u'', u'composer': u'Algy Ward/Chris Millar/Dave Vanian/Ray Burns', u'year': 2004, u'id': u'a5f01a93-5f92-3842-9f27-b82133b24707', u'subjectToCuration': False, u'album': u'Machine Gun Etiquette [25th Anniversary Edition]', u'title': u'Smash It Up, Pt. 2 [Backing Track - Singalonga Damned][#][]', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh3.googleusercontent.com/Hwlf-9z--38HBfsMTXV8sL7xf5lmcWvxkhXPg4F3q3nZagMoov0KsLp6Vxji=s130-c-e100', u'type': 2, u'titleNorm': u'smash it up, pt. 2 [backing track - singalonga damned][#][]', u'track': 15, u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997457824269L, u'name': u'Smash It Up, Pt. 2 [Backing Track - Singalonga Damned][#][]', u'albumNorm': u'machine gun etiquette [25th anniversary edition]', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 176541, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309563677920313L, u'disc': 0, u'matchedId': u'Tzjycf4dqb3vavgfjddcs6u2uli', u'composer': u'Ray Burns', u'year': 2004, u'id': u'54eab7f9-c625-3d99-b264-481171105c45', u'subjectToCuration': False, u'album': u'Machine Gun Etiquette [25th Anniversary Edition]', u'title': u'Smash It Up, Pt. 4 [#][]', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh3.googleusercontent.com/Hwlf-9z--38HBfsMTXV8sL7xf5lmcWvxkhXPg4F3q3nZagMoov0KsLp6Vxji=s130-c-e100', u'type': 2, u'titleNorm': u'smash it up, pt. 4 [#][]', u'track': 16, u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997457824269L, u'name': u'Smash It Up, Pt. 4 [#][]', u'albumNorm': u'machine gun etiquette [25th anniversary edition]', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 117701, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309563289883808L, u'disc': 0, u'matchedId': u'T25uygggdd2ogxsfgjhz4nnb7vu', u'composer': u'Alasdair Ward/Christopher Millar/David Vanian/Raymond Burns', u'year': 2004, u'id': u'43b41b61-2b8d-32a4-b5cd-146a5dd4a1f6', u'subjectToCuration': False, u'album': u'Machine Gun Etiquette [25th Anniversary Edition]', u'title': u'Smash It Up, Pts. 1-2', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh3.googleusercontent.com/Hwlf-9z--38HBfsMTXV8sL7xf5lmcWvxkhXPg4F3q3nZagMoov0KsLp6Vxji=s130-c-e100', u'type': 2, u'titleNorm': u'smash it up, pts. 1-2', u'track': 11, u'storeId': u'T25uygggdd2ogxsfgjhz4nnb7vu', u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997351657660L, u'name': u'Smash It Up, Pts. 1-2', u'albumNorm': u'machine gun etiquette [25th anniversary edition]', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 313771, u'artistNorm': u'the damned'}]
Smash It Up ][ The Damned ][ The Best Of The Damned ][ 5
upload failed - skipping
Adding: 12 - Reward.m4a
[{u'comment': u'', u'rating': 0, u'lastPlayed': 1355180352422837L, u'disc': 0, u'matchedId': u'', u'composer': u'', u'year': 1978, u'id': u'0aaf1f5b-1be1-314c-9754-81803dc610d2', u'subjectToCuration': False, u'album': u'Sound Of The Suburbs', u'title': u'Reward', u'deleted': False, u'albumArtist': u'Various Artists', u'albumArtUrl': u'//lh5.googleusercontent.com/U9GWqcXAjmngn_9s3h1G3WkCRD3jGTFAVdn1Uwxzid66dTCu2KwOp8XRQXaTZA=s130-c-e100', u'type': 2, u'titleNorm': u'reward', u'track': 12, u'albumArtistNorm': u'various artists', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Pop', u'playCount': 0, u'creationDate': 1355174269392382L, u'name': u'Reward', u'albumNorm': u'sound of the suburbs', u'artist': u'Various Artists', u'url': u'', u'totalDiscs': 0, u'durationMillis': 162144, u'artistNorm': u'various artists'}]
Reward ][ The Teardrop Explodes ][ The Sound of the Suburbs ][ 12
upload failed - skipping
Adding: 01 new rose.m4a
[{u'comment': u'', u'rating': 0, u'lastPlayed': 1311119432972179L, u'disc': 0, u'matchedId': u'T6qj7l2f5aqsshrkkex3tkuik54', u'composer': u'', u'year': 1993, u'id': u'519ef715-cf8f-35a9-96cc-c27f72f2541a', u'subjectToCuration': False, u'album': u'The Spaghetti Incident', u'title': u'New Rose', u'deleted': False, u'albumArtist': u"Guns N' Roses", u'albumArtUrl': u'//lh5.googleusercontent.com/GPWJJsmap_iNDfPZkOFyfM_FJXFPtC_ELn9wm65ctkrUWthgdmDt1gbmQ6EWdQ=s130-c-e100', u'type': 2, u'titleNorm': u'new rose', u'track': 2, u'storeId': u'T6qj7l2f5aqsshrkkex3tkuik54', u'albumArtistNorm': u"guns n' roses", u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Hard Rock', u'playCount': 0, u'creationDate': 1310765698383335L, u'name': u'New Rose', u'albumNorm': u'the spaghetti incident', u'artist': u"Guns N' Roses", u'url': u'', u'totalDiscs': 0, u'durationMillis': 158429, u'artistNorm': u"guns n' roses"}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309568198589664L, u'disc': 0, u'matchedId': u'Tz7f7s7pofftrbf7wx2cfafapli', u'composer': u'', u'year': 1979, u'id': u'e46786d2-70c7-3898-9c11-5af186143120', u'subjectToCuration': False, u'album': u'The Best Of The Damned', u'title': u'new rose', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh4.googleusercontent.com/WI2J5Vj0uZquE4NcPdQfOAnIT5klA8FZCdPTsZpShwFm0cXZz6V6n7IT12JW=s130-c-e100', u'type': 2, u'titleNorm': u'new rose', u'track': 1, u'storeId': u'Tz7f7s7pofftrbf7wx2cfafapli', u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Punk', u'playCount': 0, u'creationDate': 1308997468462075L, u'name': u'new rose', u'albumNorm': u'the best of the damned', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 164141, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309565728906475L, u'disc': 0, u'matchedId': u'T2zo2buxv5sayavrafzmb6shhce', u'composer': u'Brian James', u'year': 1994, u'id': u'77b72ac9-d985-30d3-a188-16666f4fa72f', u'subjectToCuration': False, u'album': u'Sessions of the Damned', u'title': u'New Rose', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh5.googleusercontent.com/512zAzfTHd527dV6FnJaDp3qIlSBW4K10bsY55sZen4H4XMhQpbFmgQ2tm4=s130-c-e100', u'type': 2, u'titleNorm': u'new rose', u'track': 3, u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997457824269L, u'name': u'New Rose', u'albumNorm': u'sessions of the damned', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 161773, u'artistNorm': u'the damned'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1309562360265906L, u'disc': 0, u'matchedId': u'Tz7f7s7pofftrbf7wx2cfafapli', u'composer': u'Brian James', u'year': 1977, u'id': u'14ac239d-cd3b-3a37-b224-5240d09a248d', u'subjectToCuration': False, u'album': u'Damned Damned Damned', u'title': u'New Rose', u'deleted': False, u'albumArtist': u'The Damned', u'albumArtUrl': u'//lh3.googleusercontent.com/4nc4g8lSiVA4alcy68xpvKW5vSlpX6Q5v7wYvHEAzpRJ--aYMZ0WI6nqns2Q=s130-c-e100', u'type': 2, u'titleNorm': u'new rose', u'track': 7, u'storeId': u'Tz7f7s7pofftrbf7wx2cfafapli', u'albumArtistNorm': u'the damned', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Alternative', u'playCount': 0, u'creationDate': 1308997351657660L, u'name': u'New Rose', u'albumNorm': u'damned damned damned', u'artist': u'The Damned', u'url': u'', u'totalDiscs': 0, u'durationMillis': 164699, u'artistNorm': u'the damned'}]
New Rose ][ The Damned ][ The Best Of The Damned ][ 1
upload failed - skipping
Adding: 4 - 'Another Girl, Another Planet'.m4a
[{u'comment': u'', u'rating': 0, u'lastPlayed': 1355180830473009L, u'disc': 0, u'matchedId': u'', u'composer': u'Perrett', u'year': 1978, u'id': u'61e0e3ae-532d-3521-8239-b251679f245f', u'subjectToCuration': False, u'album': u'Sound Of The Suburbs', u'title': u'Another Girl Another Planet', u'deleted': False, u'albumArtist': u'Various Artists', u'albumArtUrl': u'//lh6.googleusercontent.com/dcTpnLzSbIX0Etip6i2hu1k316YEKrGOX-lkrQazh5Ap_DQXhFKXf_92stz9Xg=s130-c-e100', u'type': 2, u'titleNorm': u'another girl another planet', u'track': 4, u'albumArtistNorm': u'various artists', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'Pop', u'playCount': 0, u'creationDate': 1355174269392382L, u'name': u'Another Girl Another Planet', u'albumNorm': u'sound of the suburbs', u'artist': u'The Only Ones', u'url': u'', u'totalDiscs': 0, u'durationMillis': 179977, u'artistNorm': u'the only ones'}, {u'comment': u'', u'rating': 0, u'lastPlayed': 1312003647961141L, u'disc': 0, u'matchedId': u'Tz7sj2haodlqcy2poe3iioayl2m', u'composer': u'', u'year': 1978, u'id': u'c7b1ff6e-6b26-32d7-8107-6df5add4700c', u'subjectToCuration': False, u'album': u'The Only Ones', u'title': u'Another Girl, Another Planet', u'deleted': False, u'albumArtist': u'The Only Ones', u'albumArtUrl': u'//lh4.googleusercontent.com/JeYwuBASTcGWpLmJbiubdlfIL4URVY5sEahZIFoatUvNdD-B6zr0grGTI7Bp=s130-c-e100', u'type': 2, u'titleNorm': u'another girl, another planet', u'track': 2, u'storeId': u'Tz7sj2haodlqcy2poe3iioayl2m', u'albumArtistNorm': u'the only ones', u'totalTracks': 0, u'beatsPerMinute': 0, u'genre': u'New Wave', u'playCount': 0, u'creationDate': 1310768074996073L, u'name': u'Another Girl, Another Planet', u'albumNorm': u'the only ones', u'artist': u'The Only Ones', u'url': u'', u'totalDiscs': 0, u'durationMillis': 180001, u'artistNorm': u'the only ones'}]
Another Girl Another Planet ][ The Only Ones ][ The Sound of the Suburbs ][ 4
upload failed - skipping
482 songs unmodified
0 songs added
4 songs failed
0 songs removed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.