Last active
October 12, 2016 05:55
-
-
Save matchy256/8570833 to your computer and use it in GitHub Desktop.
rec_radiko.sh / rec_nhk.sh で録音したmp3ファイルをパラメータに渡すと GoogleMusic にアップロードしてファイル名から日付をカットしたプレイリストに整理するスクリプト。要 https://github.com/simon-weber/Unofficial-Google-Music-API 。Google ID とパスワードは自分のものに書き換えること
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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