本文整理汇总了Python中mutagen.File.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python File.iteritems方法的具体用法?Python File.iteritems怎么用?Python File.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mutagen.File
的用法示例。
在下文中一共展示了File.iteritems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import iteritems [as 别名]
def parse(self):
print os.path.abspath(self.filename)
tag = MutagenFile(self.filename)
if tag == None:
print self.filename
else:
for key, value in tag.iteritems():
if key in GENERAL_KEYS.keys():
self.dict[ GENERAL_KEYS[key] ] = unicode(value)
elif key in MP3_KEYS.keys():
self.dict[ MP3_KEYS[key] ] = unicode(value)
elif key in MP4_KEYS.keys():
self.dict[ MP4_KEYS[key] ] = unicode(value)
示例2: Metadata
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import iteritems [as 别名]
class Metadata(object):
"""Get the metadata for a file.
Data you probably need:
artist
title
album
tracknumber
date"""
def __init__(self, filename):
self._audio = File(filename, easy=True)
for k, v in self._audio.iteritems():
# drop any unicode character we can't decode into ascii so md5
# works (because md5 uses bytes, not characters)
self._audio[k] = v[0].encode("ascii", "ignore")
def __getattr__(self, name):
return self._audio[name][0]
示例3: Vorbis
# 需要导入模块: from mutagen import File [as 别名]
# 或者: from mutagen.File import iteritems [as 别名]
class Vorbis(object):
def __init__(self, filename):
self.filename = filename
ext = os.path.splitext(filename)[1].lower()
if ext == u'.flac':
self.file = FLAC(filename)
elif ext == u'.wma':
self.file = ASF(filename)
elif ext == u'.wv':
self.file = WavPack(filename)
elif ext in [u'.mpc', u'.mpp', u'.mp+']:
self.file = Musepack(filename)
elif ext in [u'.ogg', u'.ape']:
self.file = File(filename)
else:
raise TypeError
def readAll(self):
return {k: unicode(v[0]) for k, v in self.file.iteritems()}