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


Python MPDClient.sticker_list方法代码示例

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


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

示例1: main

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import sticker_list [as 别名]
def main(action, uri, name, value):
    client = MPDClient()
    client.connect(HOST, PORT)
    if PASS:
        client.password(PASS)

    if action == "get":
        print client.sticker_get("song", uri, name)
    if action == "set":
        client.sticker_set("song", uri, name, value)
    if action == "delete":
        client.sticker_delete("song", uri, name)
    if action == "list":
        stickers = client.sticker_list("song", uri)
        for sticker in stickers:
            print sticker
    if action == "find":
        matches = client.sticker_find("song", uri, name)
        for match in matches:
            if "file" in match:
                print match["file"]
开发者ID:abednarski79,项目名称:mpd-lirc,代码行数:23,代码来源:GoodCommandExample.py

示例2: MPDBookmark

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import sticker_list [as 别名]
class MPDBookmark(object):
    def __init__(self, host="localhost", port=6600, password=None,
                 motif="Podcast", field="album"):
        self.client = MPDClient()
        try:
            self.client.connect(host, port)
            if password:
               self.client.password(password) 
            
        except :
            print "merde"
            print "host = ", host
            print "port = ", port
            print "pass = ", password
            assert False
        self.motif=motif
        self.field=field
        self.boucle()

    def stats(self):
        print "==========================================="
        print "                Version :"
        print self.client.mpd_version
        print "==========================================="
        print "fin du test"
        print self.client.status()


    def wait_action(self):
        self.client.send_idle('player')
        select([self.client], [], [], 60)
        return self.client.fetch_idle()

    
    def verif_motif(self, song):
        return  self.field in song and re.match(self.motif, song[self.field])

    
    def update_song(self, song, ts):
        new_ts=time.time()
        if 'title' in song :
            print "Update song : ", song['title'],
            print "( ",int(new_ts-ts),
            print "/",song['time']," )"
        if self.verif_motif(song):
            last_up=int(new_ts-ts)
            self.client.sticker_set('song', song['file'], 
                                    'last_up', last_up)
    
    def start_song(self, new_song):
        if ('file' in new_song) and 'last_up' in self.client.sticker_list('song', new_song['file']):
            last_up=int(self.client.sticker_get('song', 
                                                new_song['file'], 
                                                'last_up'))
            if abs(int(new_song['time'])-last_up)<=4 :
                last_up=0
            self.client.seekcur(last_up)


    def boucle(self):
        

        state=self.client.status()['state']
        song=self.client.currentsong()
        print "song  :  ", song
        ts=time.time()
        if 'elapsed' in song :
            ts-=float( song['elapsed'])

        while 1 :
            ret=self.wait_action()
            new_state=self.client.status()['state']
            new_song=self.client.currentsong()

            if new_song!=song and new_song!={}:
                self.start_song(new_song)

            if song !={}:
                print "update  ",
                self.update_song(song, ts)

            state= new_state
            song= new_song
            if 'elapsed' in self.client.status():
                ts=time.time()-float( self.client.status()['elapsed'])
开发者ID:RaoulChartreuse,项目名称:mpd_bookmark,代码行数:87,代码来源:mpd_bookmark.py


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