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


Python OggVorbis.get方法代码示例

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


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

示例1: getFileInfoFromMeta

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
    def getFileInfoFromMeta(self, filepath):
        artist = ''
        title = ''
        genre = ''

        musicfile = self.getMusicForCdg(filepath)
        if musicfile:
            name, ext = os.path.splitext(musicfile)
            print "Name:", name
            print "Ext:", ext
            if ext == '.mp3':
                print "MP3"
                try:
                    eid = EasyID3(musicfile)
                    artist = eid.get('artist', [''])[0]
                    title = eid.get('title', [''])[0]
                    genre = eid.get('genre', ['karaoke'])[0]
                    print "Got: (%s, %s, %s)" % (artist, title, genre)
                except ID3NoHeaderError:
                    print "No ID Header for", musicfile
            elif ext == '.ogg':
                audio = OggVorbis(musicfile)
                artist = audio.get('artist', '')[0]
                title = audio.get('title', '')[0]
                genre = audio.get('genre', ['karaoke'])[0]

        return artist, title, genre
开发者ID:kubilus1,项目名称:emptyorchestra,代码行数:29,代码来源:emptyorch.py

示例2: _get_OGG_tags

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
def _get_OGG_tags(filename):
    tagsOGG = OggVorbis(filename)
    tags = {}
    tags['album'] = ''.join(tagsOGG.get('album', ['']))
    tags['title'] = ''.join(tagsOGG.get('title', ['']))
    tags['artist'] = ''.join(tagsOGG.get('artist', ['']))
    tags['length'] = tagsOGG.info.length * 1000
    tags['genre'] = 'Podcast'
    return tags
开发者ID:ortylp,项目名称:gpodder-hook-scripts,代码行数:11,代码来源:movetoipod.py

示例3: __song_ogg

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
 def __song_ogg(filename):
     f = OggVorbis(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)
开发者ID:nickbp,项目名称:misc-utils,代码行数:12,代码来源:gmusic-ratings.py

示例4: get_file_info

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
def get_file_info(filename):
    # Get needed information from file
    name, ext = os.path.splitext(os.path.basename(filename))
    if ext.lower() == ".mp3":
        track = MP3(filename)
        data = ID3(filename)
        title = data["TIT2"].text[0]
    elif ext.lower() == ".ogg":
        track = OggVorbis(filename)
        title = str(track.get("title")).strip('[u"]')
    elif ext.lower() == ".flac":
        track = FLAC(filename)
        title = str(track.get("title")).strip('[u"]')
    return title, int(track.info.length)
开发者ID:LeMeD,项目名称:faustus,代码行数:16,代码来源:pls-maker.py

示例5: parse_metadata

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
def parse_metadata(f, def_title="N/A", def_artist="N/A", def_album="N/A", def_track=1):
	try:
		if (f.endswith(".mp3")):
			m = EasyID3(f)
		elif (f.endswith(".m4a")):
			m = EasyMP4(f)
		elif (f.endswith(".ogg")):
			m = OggVorbis(f)
	except:
		return (def_title, def_artist, def_album)
	title = m.get("title", [def_title])[0]
	artist = m.get("artist", [def_artist])[0]
	album = m.get("album", [def_album])[0]
	track = m.get("tracknumber", [def_track])[0]
	length = m.info.length
	bitrate = m.info.bitrate
	return (title.encode("utf-8"), artist.encode("utf-8"), album.encode("utf-8"), track.encode("utf-8"), length, bitrate)
开发者ID:beakdoctor,项目名称:diapason,代码行数:19,代码来源:createdb.py

示例6: parse_metadata

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
def parse_metadata(f, def_title="N/A", def_artist="N/A", def_album="N/A", def_track=1):
    try:
        if f.endswith(".mp3"):
            m = EasyID3(f)
        elif f.endswith(".m4a"):
            m = EasyMP4(f)
        elif f.endswith(".ogg"):
            m = OggVorbis(f)
    except:
        return (def_title, def_artist, def_album)
    title = m.get("title", [def_title])[0]
    artist = m.get("artist", [def_artist])[0]
    album = m.get("album", [def_album])[0]
    # tracknumber is a string. We would like it as a number (because we sort by it).
    try:
        track = int(m.get("tracknumber", [def_track])[0])
    except ValueError:
        track = def_track
        # length is floating point number, but we'd rather have it as an int.
    length = int(m.info.length)
    bitrate = m.info.bitrate
    return (title.encode("utf-8"), artist.encode("utf-8"), album.encode("utf-8"), track, length, bitrate)
开发者ID:beakdoctor,项目名称:diapason-plus,代码行数:24,代码来源:musicdb.py

示例7: __init__

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
    def __init__(self, path):
        """ Read metainformation from an ogg file

        Keyword arguments:
        path -- the full path to the song
        """
        super(VorbisSong, self).__init__(path)
        self.codec = "vorbis"
        song = OggVorbis(self.path)

        for key in ("title", "artist", "album", "genre", "date"):
            attr = song.get(key, ("",))[0]
            setattr(self, key, attr.encode("utf-8"))
        self.bitrate = int(song.info.bitrate) / 1000
        self.length = int(song.info.length)

        # check for empty track number
        try:
            self.tracknumber = int(song["tracknumber"][0])
        except (ValueError, KeyError):
            self.tracknumber = 0
开发者ID:MinchinWeb,项目名称:Laudio,代码行数:23,代码来源:vorbis.py

示例8: OGGSong

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
class OGGSong (Song):

    def __init__(self, path):
        """ Read metainformation from an ogg file
        The multiple KeyErrors check if tags are not Null
        Keyword arguments:
        path -- the full path to the song
        """
        self.codec = "ogg"
        self.path = path
        self.song = OggVorbis(self.path)
        for key in ('title', 'artist', 'album', 'genre', 'date'):
            attr = self.song.get(key, ('',))[0]
            setattr(self, key, attr.encode("utf-8") )
        self.bitrate = int(self.song.info.bitrate) / 1000
        self.length = int(self.song.info.length)
        if self.title == "":
            self.title = os.path.basename(self.path)
        # check for empty track number
        try:
            self.tracknumber = int(self.song['tracknumber'][0])
        except (ValueError, KeyError):
            self.tracknumber = 0
开发者ID:jgehring,项目名称:Laudio,代码行数:25,代码来源:ogg.py

示例9: __init__

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
class VorbisFile:
    def __init__(self, fn):
        self.config = config

        if fn is not None:
            self.SetFile(fn)

    def SetFile(self, fn):
        self.fn = fn
        self.filename = os.path.basename(self.fn)
        self.af = OggVorbis(self.fn)

    def read_comments(self):
        dic = {'title' : '',
               'artist' : '',
               'album' : '',
               'license' : '',
               'label' : '',
               'comment' : ''
              }
	for tag in self.af.keys():
	    tag = tag.lower()
            val = self.af.get(tag).pop(0)
            if val <> '': dic[tag] = val
        return dic

    def write_comments(self, metadata, userInfo, cache=1, removeSpool=0):
        '''
	Cache the file (copy it to a tmp dir) and write the tags there.
        '''

        logger.debug99("called VorbisFile.write_comments()")

        # now write the comments to file (self.af)
	dic = {}
	for tag in metadata:
	    tag = tag.lower()
            val = metadata[tag]

	    # build up metadata object together with audio file object
            if val != '':
                self.af[tag] = val
            else:
                logger.debug3("Not writing tag: %s (was left empty)" % tag)

	self.af.save()
        logger.debug3( "in VorbisFile.write_comments() Done! Wrote tags successfully to %s!" % self.fn )

        # FIXME : el ImportOGG en modo 'edit' es para que re-lea tags y actualice la DB
	#         pero no deberia ir dentro de la clase VorbisFile
        '''
        if not cache:
            logger.debug2("Should re-import/update: %s" % self.fn)
            ImportOGG(self, self.fn, userInfo, 'edit')
        '''
	return self.fn

    def getFilepath(self):
        return self.fn

    def getFilename(self):
        return self.filename

    def getTag(self, tag):
        if self.af.has_key(tag) and self.af[tag] is not '':
            return self.af.get(tag).pop(0)
        else: return ''

    def getLength(self):
        return self.af.info.length

    def getBitrate(self):
        return self.af.info.bitrate

    def getSamplerate(self):
        return self.af.info.sample_rate

    def getInfo(self):
	'''Available info (for OGG/Vorbis) is:  channels, bitrate, serial, sample_rate, length'''
        return self.af.info

    def listTags(self):
        return self.af.keys()

    def getSize(self):
        return os.stat(self.fn).st_size
开发者ID:Xicnet,项目名称:burnstation,代码行数:88,代码来源:VorbisFile.py

示例10: get_album_artist

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
 def get_album_artist(self):
     """Return the album artist (performer) from Vorbis comments."""
     file_path = os.path.join(settings.MEDIA_ROOT, self.file.name)
     tags = OggVorbis(file_path)
     return tags.get('performer', '').strip()
开发者ID:jmichalicek,项目名称:djukebox,代码行数:7,代码来源:models.py

示例11: get_album

# 需要导入模块: from mutagen.oggvorbis import OggVorbis [as 别名]
# 或者: from mutagen.oggvorbis.OggVorbis import get [as 别名]
 def get_album(self):
     """Return the album from Vorbis comments."""
     file_path = os.path.join(settings.MEDIA_ROOT, self.file.name)
     tags = OggVorbis(file_path)
     return tags.get('album', [''])[0].strip()
开发者ID:jmichalicek,项目名称:djukebox,代码行数:7,代码来源:models.py


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