當前位置: 首頁>>代碼示例>>Python>>正文


Python Musicmanager.download_song方法代碼示例

本文整理匯總了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)
開發者ID:djeebus,項目名稱:gmusic-cli,代碼行數:13,代碼來源:cli.py

示例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)
開發者ID:Westie1012,項目名稱:gmusic-streaming,代碼行數:23,代碼來源:download.py


注:本文中的gmusicapi.Musicmanager.download_song方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。