Create a gist now

Instantly share code, notes, and snippets.

rec_radiko.sh / rec_nhk.sh で録音したmp3ファイルをパラメータに渡すと GoogleMusic にアップロードしてファイル名から日付をカットしたプレイリストに整理するスクリプト。要 https://github.com/simon-weber/Unofficial-Google-Music-API 。Google ID とパスワードは自分のものに書き換えること
#!/usr/bin/env python
from gmusicapi import Musicmanager
from gmusicapi import Mobileclient
import sys
import os.path
params = sys.argv
mm = Musicmanager()
api = Mobileclient()
mm.login()
api.login('GoogleID', 'Password')
for i in range(1, len(params)):
file = params[i]
track = mm.upload(file)
track_id = track[0][file]
listname,ext = os.path.splitext(os.path.basename(file))
listname = listname[:-17]
playlist_id = None
playlists = api.get_all_playlists()
for playlist in playlists:
if listname == playlist['name']:
playlist_id = playlist['id']
break
if playlist_id == None:
playlist_id = api.create_playlist(listname)
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