• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python daap.do函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spydaap.daap.do函数的典型用法代码示例。如果您正苦于以下问题:Python do函数的具体用法?Python do怎么用?Python do使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: parse

    def parse(self, trk):
        try:
            #trk = mutagen.File(filename)
            d = []
            if len(trk.list_tags()) > 0:
                if 'title' in trk.list_tags():
                    name = str(trk.get_tag_raw('title')[0])
                else: 
                    name = str(trk)
                
                self.handle_string_tags(self._string_map, trk, d)
                self.handle_int_tags(self._int_map, trk, d)
#                self.handle_rating(trk, d)
            else: 
                name = str(trk)
            #statinfo = os.stat(filename)

            _len = trk.get_tag_raw('__length')
            if _len is None:    # don't parse songs that don't have length
                return (None, None)

            d.extend([#do('daap.songsize', trk.get_size()),
                      #do('daap.songdateadded', statinfo.st_ctime),
                      #do('daap.songdatemodified', statinfo.st_ctime),
                      do('daap.songtime', _len * 1000),
#                      do('daap.songbitrate', trk.get_tag_raw('__bitrate') / 1000),
#                      do('daap.songsamplerate', ogg.info.sample_rate), # todo ??
                      do('daap.songformat', trk.get_local_path().split('.')[-1]), # todo ??
                      do('daap.songdescription', 'Exaile Streaming Audio'),
                      ])
            return (d, name)
            
        except Exception:
            logger.exception('caught exception while processing %s', trk)
            return (None, None)    
开发者ID:Zarokka,项目名称:exaile,代码行数:35,代码来源:exaile.py


示例2: build_item

 def build_item(md):
     return do('dmap.listingitem', 
               [ do('dmap.itemkind', 2),
                 do('dmap.containeritemid', md.id),
                 do('dmap.itemid', md.id),
                 md.get_dmap_raw()
                 ])
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:7,代码来源:server.py


示例3: parse

 def parse(self, filename):
     d = []
     mp3 = None
     try:
         mp3 = mutagen.mp3.MP3(filename)
     except mutagen.mp3.HeaderNotFoundError:
         pass
     except struct.error:
         pass
     if mp3 != None:
         if mp3.tags != None:
             self.handle_string_tags(self.mp3_string_map, mp3, d)
             self.handle_int_tags(self.mp3_int_map, mp3, d)
             self.handle_rating(mp3, d)
             self.handle_track(mp3, d)
             self.handle_disc(mp3, d)
         self.add_file_info(filename, d)
         d.extend([do('daap.songtime', mp3.info.length * 1000),
                   do('daap.songbitrate', mp3.info.bitrate / 1000),
                   do('daap.songsamplerate', mp3.info.sample_rate),
                   do('daap.songformat', 'mp3'),
                   do('daap.songdescription', 'MPEG Audio File'),
                   ])
         name = self.set_itemname_if_unset(os.path.basename(filename), d)
         return (d, name)
     else:
         return (None, None)
开发者ID:edgimar,项目名称:spydaap,代码行数:27,代码来源:mp3.py


示例4: build_do

 def build_do(md, id):
     d = do('dmap.listingitem',
            [ do('dmap.itemkind', 2),
              do('dmap.itemid', md.id),
              do('dmap.itemname', md.get_name()),
              do('dmap.containeritemid', id)
              ] )
     return d
开发者ID:BlubberHarpoonist,项目名称:exaile,代码行数:8,代码来源:containers.py


示例5: handle_disc

 def handle_disc(self, mp3, d):
     discnumber = None
     disccount = None
     if mp3.tags.has_key('TPOS'):
         t = str(mp3.tags['TPOS']).split('/')
         discnumber = self.my_int(t[0])
         if (len(t) == 2):
             disccount = self.my_int(t[1])
     if discnumber: d.append(do('daap.songdiscnumber', discnumber))
     if disccount: d.append(do('daap.songdisccount', disccount))
开发者ID:edgimar,项目名称:spydaap,代码行数:10,代码来源:mp3.py


示例6: handle_track

 def handle_track(self, mp3, d):
     tracknumber = None
     trackcount = None
     if mp3.tags.has_key('TRCK'):
         t = str(mp3.tags['TRCK']).split('/')
         tracknumber = self.my_int(t[0])
         if (len(t) == 2):
             trackcount = self.my_int(t[1])
     if tracknumber: d.append(do('daap.songtracknumber', tracknumber))
     if trackcount: d.append(do('daap.songtrackcount', trackcount))
开发者ID:edgimar,项目名称:spydaap,代码行数:10,代码来源:mp3.py


示例7: handle_disc

 def handle_disc(self, flac, d):
     discnumber = None
     disccount = None
     if flac.tags.has_key('discnumber'):
         t = unicode(flac.tags['discnumber'][0]).split('/')
         discnumber = self.my_int(t[0])
         if (len(t) == 2):
             disccount = self.my_int(t[1])
     if flac.tags.has_key('disctotal'):
         disccount = self.my_int(flac.tags['disctotal'])
     if discnumber: d.append(do('daap.songdiscnumber', discnumber))
     if disccount: d.append(do('daap.songdisccount', disccount))
开发者ID:edgimar,项目名称:spydaap,代码行数:12,代码来源:vorbis.py


示例8: handle_track

 def handle_track(self, flac, d):
     tracknumber = None
     trackcount = None
     if flac.tags.has_key('tracknumber'):
         t = str(flac.tags['tracknumber']).split('/')
         tracknumber = self.my_int(t[0])
         if (len(t) == 2):
             trackcount = self.my_int(t[1])
     if flac.tags.has_key('tracktotal'):
         trackcount = self.my_int(flac.tags['tracktotal'])
     if tracknumber: d.append(do('daap.songtracknumber', tracknumber))
     if trackcount: d.append(do('daap.songtrackcount', trackcount))
开发者ID:edgimar,项目名称:spydaap,代码行数:12,代码来源:vorbis.py


示例9: parse

 def parse(self, filename):
     md = mutagen.File(filename)
     d = []
     if md.tags != None:
         self.handle_string_tags(self.vorbis_string_map, md, d)
         self.handle_int_tags(self.vorbis_int_map, md, d)
         self.handle_track(md, d)
         self.handle_disc(md, d)
     self.add_file_info(filename, d)
     d.extend([do('daap.songtime', md.info.length * 1000),
               do('daap.songsamplerate', md.info.sample_rate)])
     name = self.set_itemname_if_unset(os.path.basename(filename), d)
     if hasattr(self, 'parse_extra_vorbis'):
         self.parse_extra_vorbis(filename, md, d)
     return (d, name)
开发者ID:edgimar,项目名称:spydaap,代码行数:15,代码来源:vorbis.py


示例10: handle_int_tags

 def handle_int_tags(self, map, md, daap):
     for k in md.list_tags():
         if map.has_key(k):
             try:
                 tn = str(md.get_tag_raw(k)[0])
                 if '/' in tn: #
                     num, tot = tn.split('/')
                     if num == '':           # empty tags
                         num = 0
                     daap.append(do(map[k], int(num)))
                     # set total?
                 else:
                     daap.append(do(map[k], int(tn)))
             except Exception:
                 logger.exception('exception caught parsing tag: %s=%s from %s',
                     k, tn, md)
开发者ID:Zarokka,项目名称:exaile,代码行数:16,代码来源:exaile.py


示例11: handle_int_tags

 def handle_int_tags(self, map, md, daap):
     for k in md.list_tags():
         if map.has_key(k):
             try:
                 tn = str(md.get_tag_raw(k)[0])
                 if '/' in tn: #
                     num, tot = tn.split('/')
                     if num == '':           # empty tags
                         num = 0
                     daap.append(do(map[k], int(num)))
                     # set total?
                 else:
                     daap.append(do(map[k], int(tn)))
             except Exception:
                 logger.debug('exception caught parsing tag: {0}={1} from {2}'
                     .format(k, tn, md))
                 logger.debug(traceback.format_exc()) 
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:17,代码来源:exaile.py


示例12: handle_int_tags

 def handle_int_tags(self, map, md, daap):
     for k in md.tags.keys():
         if map.has_key(k):
             val = md.tags[k]
             if type(val) == list:
                 val = val[0]
             intval = self.my_int(unicode(val))
             if intval: daap.append(do(map[k], intval))
开发者ID:BlubberHarpoonist,项目名称:exaile,代码行数:8,代码来源:__init__.py


示例13: handle_string_tags

 def handle_string_tags(self, map, md, daap):
     for k in md.list_tags():
         if map.has_key(k):
             try:
                 tag = [ str(t) for t in md.get_tag_raw(k)]
                 tag = [ t for t in tag if t != ""]
                 daap.append(do(map[k], "/".join(tag)))
             except Exception:
                 logger.debug(traceback.format_exc()) 
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:9,代码来源:exaile.py


示例14: handle_string_tags

 def handle_string_tags(self, map, md, daap):
     for k in md.list_tags():
         if map.has_key(k):
             try:
                 tag = [ str(t) for t in md.get_tag_raw(k)]
                 tag = [ t for t in tag if t != ""]
                 daap.append(do(map[k], "/".join(tag)))
             except Exception:
                 logger.exception("error decoding tags") 
开发者ID:Zarokka,项目名称:exaile,代码行数:9,代码来源:exaile.py


示例15: handle_string_tags

 def handle_string_tags(self, map, md, daap):
     for k in md.list_tags():
         if k in map:
             try:
                 tag = [t.encode("utf-8", "replace") for t in md.get_tag_raw(k)]
                 tag = [t for t in tag if t != ""]
                 daap.append(do(map[k], "/".join(tag)))
             except Exception:
                 logger.exception("error decoding tags")
开发者ID:exaile,项目名称:exaile,代码行数:9,代码来源:exaile_parser.py


示例16: handle_int_tags

 def handle_int_tags(self, map, md, daap):
     for k in md.tags.keys():
         if k in map:
             val = md.tags[k]
             if isinstance(val, list):
                 val = val[0]
             intval = self.my_int(unicode(val))
             if intval:
                 daap.append(do(map[k], intval))
开发者ID:egh,项目名称:spydaap,代码行数:9,代码来源:__init__.py


示例17: handle_string_tags

 def handle_string_tags(self, map, md, daap):
     h = {}
     for k in md.tags.keys():
         if map.has_key(k):
             tag = [ unicode(t) for t in md.tags[k] ]
             tag = [ t for t in tag if t != "" ]
             if not(h.has_key(map[k])): h[map[k]] = []
             h[map[k]] = h[map[k]] + tag
     for k in h.keys():
         h[k].sort()
         daap.append(do(k, "/".join(h[k])))
开发者ID:BlubberHarpoonist,项目名称:exaile,代码行数:11,代码来源:__init__.py


示例18: get_md

 def get_md(self):
     if self.md is None:
         self.md = {}
         s = StringIO.StringIO(self.get_dmap_raw())
         l = len(self.get_dmap_raw())
         data = []
         while s.tell() != l:
             d = do()
             d.processData(s)
             data.append(d)
         for d in data:
             self.md[d.codeName()] = d.value
     return self.md
开发者ID:egh,项目名称:spydaap,代码行数:13,代码来源:metadata.py


示例19: build_do

 def build_do(md, id):
     d = do('dmap.listingitem',
            [do('dmap.itemkind', 2),
             do('dmap.itemid', md.id),
             do('dmap.itemname', md.get_name()),
             do('dmap.containeritemid', id),
             do('daap.songformat', md.get_md()['daap.songformat'])])
     return d
开发者ID:egh,项目名称:spydaap,代码行数:8,代码来源:containers.py


示例20: build

 def build():
     children = [ build_item (md) for md in md_cache ]
     file_count = len(children)
     d = do('daap.databasesongs',
            [ do('dmap.status', 200),
              do('dmap.updatetype', 0),
              do('dmap.specifiedtotalcount', file_count),
              do('dmap.returnedcount', file_count),
              do('dmap.listing',
                 children) ])
     return d.encode()
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:11,代码来源:server.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base._函数代码示例发布时间:2022-05-27
下一篇:
Python spwd.getspnam函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap