Skip to content

Instantly share code, notes, and snippets.

Last active October 17, 2018 13:35
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
GoogleMusic に音声ファイルをアップロードするスクリプト。要 。第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]"
file = params[1]
if len(params) == 3:
plname = params[2]
plname = None
mm = Musicmanager()
api = Mobileclient()
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']
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