本文整理匯總了Python中gmusicapi.Musicmanager.download_song方法的典型用法代碼示例。如果您正苦於以下問題:Python Musicmanager.download_song方法的具體用法?Python Musicmanager.download_song怎麽用?Python Musicmanager.download_song使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gmusicapi.Musicmanager
的用法示例。
在下文中一共展示了Musicmanager.download_song方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: download_user_track
# 需要導入模塊: from gmusicapi import Musicmanager [as 別名]
# 或者: from gmusicapi.Musicmanager import download_song [as 別名]
def download_user_track(mgr: gmusicapi.Musicmanager, full_path, track):
dirname = os.path.dirname(full_path)
fp, temp_path = tempfile.mkstemp(dir=dirname)
try:
fname, audio = mgr.download_song(track['id'])
fp.write(audio)
os.rename(temp_path, full_path)
finally:
if os.path.exists(temp_path):
os.unlink(temp_path)
示例2: Musicmanager
# 需要導入模塊: from gmusicapi import Musicmanager [as 別名]
# 或者: from gmusicapi.Musicmanager import download_song [as 別名]
from gmusicapi import Musicmanager
import os.path
storage_filepath = '/home/alex/.local/share/gmusicapi/oauth.cred'
mm = Musicmanager()
if os.path.isfile(storage_filepath):
mm.login()
else:
Musicmanager.perform_oauth(storage_filepath, open_browser=True)
songs = mm.get_uploaded_songs(incremental=False)
print(songs)
song_id = []
for x in songs:
song_id.append(x.get('id'))
print(song_id)
for an_id in song_id:
filename, audio = mm.download_song(an_id)
with open(filename, 'wb') as f:
f.write(audio)
input("Enter: ")
mm.logout(revoke_oauth=False)