当前位置: 首页>>代码示例>>Python>>正文


Python Track.albumarturl方法代码示例

本文整理汇总了Python中track.Track.albumarturl方法的典型用法代码示例。如果您正苦于以下问题:Python Track.albumarturl方法的具体用法?Python Track.albumarturl怎么用?Python Track.albumarturl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在track.Track的用法示例。


在下文中一共展示了Track.albumarturl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initthread

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import albumarturl [as 别名]
def initthread(mwc, mc):
    library = mwc.library
    mwc.status_msg("Initializing..")
    wc = Webclient()
    wc.login(config.user, config.password)
    devices = wc.get_registered_devices()

    mwc.status_msg("Retrieving usable device ID..")
    for dev in devices:
        if dev["type"] == "PHONE":
            # strip 0x if present
            config.devid = dev["id"][2:] if dev["id"].startswith("0x") else dev["id"]
            print("Found a usable device id: " + config.devid)
            break
    else:
        md = Gtk.MessageDialog(parent=mwc.ui, buttons=Gtk.ButtonsType.OK, message_type=Gtk.MessageType.ERROR, message_format="Could not find a usable device id. Please run the Google Play Music app at least once on your phone.")
        GLib.idle_add(modal_dialog_func, md)

    mc.login(config.user, config.password)
    player = Player(mc, config.devid)
    mwc.setplayer(player)

    def getalbumart(structure):
        if "albumArtRef" in structure:
            a = structure["albumArtRef"]
            for entry in a:
                if "url" in entry:
                    return entry["url"]
        return None

    mwc.status_msg("Retrieving library..")
    songs = mc.get_all_songs()
    for song in songs:
        track = Track(song["id"], song["title"], song["artist"], song["album"],
                      song["trackNumber"] if "trackNumber" in song else 0)
        track.albumarturl = getalbumart(song)
        library.add_track(track)

    mwc.status_msg("Retrieving playlists..")
    playlists = mc.get_all_user_playlist_contents()


    for x in playlists:
        tracks = []
        for t in x["tracks"]:
            if t["trackId"].startswith("T"): # all access track
                trackEntry = t["track"]
                track = Track(t["trackId"], trackEntry["title"], trackEntry["artist"], trackEntry["album"], trackEntry["trackNumber"])
                track.albumarturl = getalbumart(trackEntry)
                tracks.append(track)

            else:
                libtrack = library.find_track(t["trackId"])
                if libtrack is not None:
                    tracks.append(libtrack)
        library.add_list(Playlist(x["name"], tracks))

    mwc.status_msg("Idle")
开发者ID:hrkfdn,项目名称:gomusic,代码行数:60,代码来源:main.py


注:本文中的track.Track.albumarturl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。