本文整理汇总了Python中mutagen.flac.FLAC.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python FLAC.iteritems方法的具体用法?Python FLAC.iteritems怎么用?Python FLAC.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.flac.FLAC
的用法示例。
在下文中一共展示了FLAC.iteritems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __song_flac
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import iteritems [as 别名]
def __song_flac(filename):
f = FLAC(filename)
artist = f.get("artist", ("",))[0]
title = f.get("title", ("",))[0]
rating = 0
for k, v in f.iteritems():
if k.startswith("rating"):
rating = SongFiles.__adjust_rating_ogg(float(v[0]))
break
return Song(filename, artist, title, rating)
示例2: tag
# 需要导入模块: from mutagen.flac import FLAC [as 别名]
# 或者: from mutagen.flac.FLAC import iteritems [as 别名]
def tag(self, flac_filename, mp3_filename):
flac = FLAC(flac_filename)
id3 = ID3()
involved_people = []
for tag, value in flac.iteritems():
if tag in self.tag_map:
id3.add(self.tag_map[tag](encoding=3, text=value))
elif tag in self.text_tag_map:
id3.add(TXXX(encoding=3, desc=self.text_tag_map[tag], text=value))
elif tag == 'tracknumber':
value[0] += self._total(flac, ['tracktotal', 'totaltracks'])
id3.add(TRCK(encoding=3, text=value))
elif tag == 'discnumber':
value[0] += self._total(flac, ['disctotal', 'totaldiscs'])
id3.add(TPOS(encoding=3, text=value))
elif tag == 'musicbrainz_trackid':
id3.add(UFID(u'http://musicbrainz.org', value[0]))
elif tag in ('producer', 'engineer', 'arranger'):
involved_people.extend((unicode(tag), v) for v in value)
elif tag == 'mixer':
involved_people.extend((u'mix', v) for v in value)
elif tag == 'performer':
id3.add(TMCL(encoding=3, people=self._performers(value)))
elif tag not in [
'tracktotal', 'totaltracks', 'disctotal', 'totaldiscs',
'replaygain_album_gain', 'replaygain_album_peak',
'replaygain_track_gain', 'replaygain_track_peak',
# Don't know what to do with reference loudness - ignore it
'replaygain_reference_loudness']:
raise UnknownTag("%s=%s" % (tag, value))
if involved_people:
id3.add(TIPL(encoding=3, people=involved_people))
self._replaygain(flac, id3, 'album')
self._replaygain(flac, id3, 'track')
for pic in flac.pictures:
tag = APIC(
encoding=3,
mime=pic.mime,
type=pic.type,
desc=pic.desc,
data=pic.data)
id3.add(tag)
id3.save(mp3_filename)