本文整理汇总了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)