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


Python MPDClient.use_unicode方法代码示例

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


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

示例1: onevent

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import use_unicode [as 别名]
def onevent(msg):
    # add song if needed
    client = MPDClient()
    client.connect("localhost", 6600)
    client.use_unicode = True
    if client.status()["playlistlength"] == '0' and autoaddstate == 1:
        song = choose_from_list(current_list)
        client.add(song)
        # while client.status()['state']=='stop':
        client.play()

    # currentsong info
    if 'player' in msg or 'playlist' in msg:
        print("publish currentsong")
        currentsong = client.currentsong()
        print(currentsong)
        # pre-treat the data if artist/title not present:
        if 'title' not in currentsong.keys():
            currentsong['artist'] = "?"
            if 'file' in currentsong.keys():
                currentsong['title'] = currentsong['file'].split('/')[-1]
        yield app.session.publish('radio.updatesong', currentsong)

        # player status info
    if ('player' in msg or
            'mixer' in msg or
            'options' in msg or
            'playlist' in msg):
        print("publish player status")
        status = client.status()
        status[u'autoadd'] = autoaddstate
        yield app.session.publish('radio.updatestatus', status)

    # playlist info
    if 'playlist' in msg:
        print("publish playlist")
        playlist = client.playlistinfo()
        print(playlist)
        playlist_trim = []
        for song in playlist:
            song_trim = {}
            if 'http' in song['file']:
                song_trim['artist'] = song['file']
                song_trim['title'] = ''
                song_trim['time'] = 9999
                song_trim['id'] = song['id']
            else:
                if 'title' not in song.keys() or 'artist' not in song.keys():
                    song_trim['artist'] = "?"
                    if 'file' in song.keys():
                        song_trim['title'] = song['file'].split('/')[-1]
                else:
                    song_trim['artist'] = song['artist']
                    song_trim['title'] = song['title']
                song_trim['id'] = song['id']
                song_trim['time'] = song['time']
            playlist_trim.append(song_trim)
        yield app.session.publish('radio.updateplaylist', playlist_trim)

    client.close()
开发者ID:crazyiop,项目名称:hipsterRadio,代码行数:62,代码来源:autoadd_update.py

示例2: dir_to_list

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import use_unicode [as 别名]
def dir_to_list(dir):
    client = MPDClient()
    client.connect("localhost", 6600)
    client.use_unicode = True
    lst = client.lsinfo(""+dir)
    client.close()
    out = [x["file"] for x in lst if "file" in x.keys()]
    return out
开发者ID:crazyiop,项目名称:hipsterRadio,代码行数:10,代码来源:autoadd_update.py

示例3: onjoined

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import use_unicode [as 别名]
def onjoined():
    print("session joined")

    while True:
        ######################
        # Publish to the topic

        client = MPDClient()
        client.connect("localhost", 6600)
        client.use_unicode = True
        event = client.idle()
        yield app.session.publish('radio.event', event)
        client.close()
        print(event)
        yield sleep(0.5)
开发者ID:crazyiop,项目名称:hipsterRadio,代码行数:17,代码来源:mpdevent.py


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