Skip to content

Instantly share code, notes, and snippets.

@matchy256
Last active October 17, 2018 13:35
Show Gist options
  • Save matchy256/8555125 to your computer and use it in GitHub Desktop.
Save matchy256/8555125 to your computer and use it in GitHub Desktop.
GoogleMusic に音声ファイルをアップロードするスクリプト。要 https://github.com/simon-weber/Unofficial-Google-Music-API 。第1引数にファイル名、第2引数にプレイリスト名(省略可)。Google ID とパスワードは自分のものに書き換えること
#!/usr/bin/env python
from gmusicapi import Musicmanager
from gmusicapi import Mobileclient
import sys
import os.path
params = sys.argv
if len(params) < 2:
print "usage:" + sys.argv[0] + " filename [playlist name]"
sys.exit()
file = params[1]
if len(params) == 3:
plname = params[2]
else:
plname = None
mm = Musicmanager()
api = Mobileclient()
mm.login()
api.login('GoogleID', 'Password')
track = mm.upload(file)
track_id = track[0][file]
if plname:
playlist_id = None
playlists = api.get_all_playlists()
for playlist in playlists:
if plname == playlist['name']:
playlist_id = playlist['id']
break
if playlist_id == None:
playlist_id = api.create_playlist(plname)
api.add_songs_to_playlist(playlist_id, track_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment