本文整理汇总了Python中mutagen.oggvorbis.OggVorbis类的典型用法代码示例。如果您正苦于以下问题:Python OggVorbis类的具体用法?Python OggVorbis怎么用?Python OggVorbis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OggVorbis类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getFileInfoFromMeta
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,代码行数:27,代码来源:emptyorch.py
示例2: on_episode_downloaded
def on_episode_downloaded(self, episode):
log(u'on_episode_downloaded(%s/%s)' % (episode.channel.title, episode.title))
filename = episode.local_filename(create=False, check_only=True)
if filename is None:
return
basename, extension = os.path.splitext(filename)
if episode.file_type() == 'audio' and extension.lower() == '.ogg':
log(u'trying to remove cover from %s' % filename)
found = False
try:
ogg = OggVorbis(filename)
for key in ogg.keys():
if key.startswith('cover'):
found = True
ogg[key]=''
if found:
log(u'removed cover from the ogg file successfully')
ogg.save()
else:
log(u'there was no cover to remove in the ogg file')
except:
None
开发者ID:marvil07,项目名称:gpodder-hook-scripts,代码行数:26,代码来源:rm_ogg_cover_hook.py
示例3: _EasyPythonMutagenOggVorbis
class _EasyPythonMutagenOggVorbis(object):
'''An interface like EasyId3, but for OggVorbis files.'''
def __init__(self, filename):
from mutagen.oggvorbis import OggVorbis
self.obj = OggVorbis(filename)
self.map = {
'album': 'album',
'comment': 'comment',
'artist': 'artist',
'title': 'title',
'albumartist': 'albumartist',
'tracknumber': 'tracknumber',
'discnumber': 'discnumber',
'composer': 'composer',
'genre': 'genre',
'description': 'description',
'website': 'www'}
def __getitem__(self, key):
return self.obj[self.map[key]]
def __setitem__(self, key, val):
self.obj[self.map[key]] = val
def __contains__(self, key):
return key in self.map and self.map[key] in self.obj
def save(self):
self.obj.save()
开发者ID:downpoured,项目名称:easypythonmutagen,代码行数:30,代码来源:easypythonmutagen.py
示例4: download_and_fix_ogg
def download_and_fix_ogg(ogg, audio_metadata, cover_art_file):
global DRY_RUN
if DRY_RUN:
print "This is a dry run. So pretending to download the ogg..."
return "/tmp/ogg"
print "Now downloading the ogg in order to set the metadata in it..."
if not LIVE and len(sys.argv) >= 6 and os.path.exists(sys.argv[5]):
ogg_local_fn = sys.argv[5]
print "(using presupplied file %s)" % ogg_local_fn
else:
f, metadata = client.get_file_and_metadata(ogg)
ogg_local_fn = fetch_file(f, metadata)
print "Successfully downloaded (to %s): now editing metadata..." % ogg_local_fn
audio = OggVorbis(ogg_local_fn)
for k in audio_metadata.keys():
audio[k] = audio_metadata[k]
# add cover art
im=Image.open(cover_art_file)
w,h=im.size
p=Picture()
imdata=open(cover_art_file,'rb').read()
p.data=imdata
p.type=3
p.desc=''
p.mime='image/jpeg';
p.width=w; p.height=h
p.depth=24
dt=p.write();
enc=base64.b64encode(dt).decode('ascii');
audio['metadata_block_picture']=[enc];
audio.save()
print "Successfully updated metadata."
return ogg_local_fn
开发者ID:stuartlangridge,项目名称:bv-publish,代码行数:33,代码来源:publish-public.py
示例5: set_start
def set_start(filename, start_time):
"""
Writes the start of the song section to file
"""
song_meta = OggVorbis(filename)
song_meta[Settings.song_start_tag] = start_time
song_meta.save()
开发者ID:paddatrapper,项目名称:top30,代码行数:7,代码来源:chart.py
示例6: add_tag
def add_tag(f, tag, value):
if f.endswith('ogg'):
audio = OggVorbis(f)
elif f.endswith('flac'):
audio = FLAC(f)
audio[tag] = value
# audio.pprint()
audio.save()
开发者ID:penicolas,项目名称:scripts,代码行数:8,代码来源:discnumber_normalize_GEN.py
示例7: Vorbis
class Vorbis(object):
tags = ['title', 'artist', 'album', 'genre', 'tracknumber']
def __init__(self, filename):
self._comment = OggVorbis(filename)
def write_random_tag(self, data):
tag = random.choice(Vorbis.tags)
self._comment[tag] = data
self._comment.save()
开发者ID:TIsles,项目名称:Feta,代码行数:8,代码来源:vorbis.py
示例8: ogg_tag
def ogg_tag(config):
print("Tagging " + config.ogg_file)
audio = OggVorbis(config.ogg_file)
# Add the tags.
for k in config.tags.keys():
audio[k] = config.tags[k]
audio.save()
开发者ID:rikai,项目名称:podpublish,代码行数:8,代码来源:encoder.py
示例9: remove_all
def remove_all(self):
if self.backup is True:
shutil.copy2(self.filename, self.output)
self.filename = self.output
mfile = OggVorbis(self.filename)
mfile.delete()
mfile.save()
开发者ID:4ZM,项目名称:Metadata-Anonymisation-Toolkit,代码行数:8,代码来源:audio.py
示例10: convert
def convert(self):
''' Convert wav -> ogg.'''
if self.songwav == self.song:
success = True
dec = None
else:
success, dec = self.decode()
if not success:
warn('Decoding of "%s" failed.' % self.song)
return
if dec and self.decoder == 'mpg123':
import mutagen
try:
info("additional option:" )
opts=['-R', str(mutagen.File(self.song).info.sample_rate)]
info(str(opts))
except:
opts=[]
else:
opts=[]
if dec:
enc = Popen(['oggenc', '-Q', '-o', self.songogg, '-q', str(self.conf.quality).replace('.', ','), '-'] + opts, stdin=dec.stdout)
enc.communicate()
dec.wait()
if dec.returncode < 0:
warn('Decoding of "%s" failed.' % self.song)
return False
elif enc.returncode < 0:
warn('Encoding of "%s" failed.' % self.song)
return False
else:
enc = call(['oggenc', '-o', self.songogg, '-q', str(self.conf.quality).replace('.', ','), self.songwav])
if enc != 0:
warn('Encoding of "%s" failed.' % self.songwav)
return False
elif not self.conf.preserve_wav and self.song != self.songwav:
os.remove(self.songwav)
if self.tags != {}:
try:
# Add tags to the ogg file
from mutagen.oggvorbis import OggVorbis
myogg = OggVorbis(self.songogg)
myogg.update(self.tags)
myogg.save()
except:
warn('Could not save the tags')
import traceback
traceback.print_exc()
return False
elif self.songwav != self.song or 'cd-' in self.decoder:
warn('No tags found...')
if self.conf.delete_input:
os.remove(self.song)
return True
开发者ID:pat1,项目名称:autoradio,代码行数:58,代码来源:dir2ogg.py
示例11: saveLabel
def saveLabel(self, file, label):
'''read file and save label tag'''
af = OggVorbis(file)
logger.info( "Tags BEFORE labelizer: " + str(af) )
af['label'] = label
af.save()
logger.info( "Tags AFTER labelizer: " + str(af) )
开发者ID:Xicnet,项目名称:burnstation,代码行数:9,代码来源:burnstation-publisher.py
示例12: test_save_split_setup_packet
def test_save_split_setup_packet(self):
fn = os.path.join(DATA_DIR, "multipage-setup.ogg")
shutil.copy(fn, self.filename)
audio = OggVorbis(self.filename)
tags = audio.tags
self.failUnless(tags)
audio.save()
self.audio = OggVorbis(self.filename)
self.failUnlessEqual(self.audio.tags, tags)
开发者ID:akerbis,项目名称:mutagen,代码行数:9,代码来源:test_oggvorbis.py
示例13: ogg_write_tags
def ogg_write_tags(self, path, tag_type, input_string):
try:
ogg_audio = OggVorbis(path) #Reading tags
except:
print ("No Ogg tag found or %r is not a valid OGG file") \
% (path.encode(sys.stdout.encoding or "utf-8", "replace"), )
return
ogg_audio[tag_type] = input_string
ogg_audio.save()
开发者ID:alsmirn,项目名称:muton,代码行数:9,代码来源:tag_writer.py
示例14: _get_OGG_tags
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,代码行数:9,代码来源:movetoipod.py
示例15: setValue
def setValue(path, tag, value):
format = os.path.splitext(path)[1]
if(format == ".mp3"):
audio = EasyID3(path)
elif(format == ".ogg"):
audio = OggVorbis(path)
audio[tag] = value
audio.save()
开发者ID:yoann01,项目名称:bullseye,代码行数:9,代码来源:tags.py
示例16: __song_ogg
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,代码行数:10,代码来源:gmusic-ratings.py
示例17: write_tags_to_ogg
def write_tags_to_ogg(path, tags):
audio = OggVorbis(path)
for dest, source in [['TITLE', 'TIT2'], ['ARTIST', 'TPE1'],
['ALBUM', 'TALB'], ['DATE', 'TDRC'],
['COPYRIGHT', 'TCOP'], ['LICENSE', 'WXXX:']]:
audio[dest] = tags[source]
audio['coverartmime'] = 'image/jpeg'
audio['coverartdescription'] = 'Radiotux_ID3Tag.jpg'
audio['coverart'] = get_ogg_coverart()
audio.save()
开发者ID:Ertenz,项目名称:contagd,代码行数:10,代码来源:tagtool.py
示例18: walk_audio_files
def walk_audio_files():
tag_count = 0
for root, dirs, files in os.walk('.'):
for name in files:
audio_set = False
if name.lower().endswith(".mp3"):
try:
audio = ID3(os.path.join(root, name))
except Exception, e:
print 'ERROR: ID3 Error %s : %s' % (e, os.path.join(root, name))
continue
if not select_audio(audio):
continue
if tag_mode == TAG_MODE_NORMAL and audio.has_key('TPE1'):
artist = audio["TPE1"]
genre = artist_to_genre(artist[0])
grouping = artist_to_groupings(artist[0])
if genre != None:
audio["TCON"] = TCON(encoding=3, text=genre)
audio_set = True
if grouping != None:
audio["TIT1"] = TIT1(encoding=3, text=grouping)
audio_set = True
else:
if audio.has_key("TIT1"):
genre = refine_genre(audio["TIT1"].text[0].split(","))
if genre != "":
print "Refining genre for artist %s from %s to %s" % (audio["TPE1"].text[0], audio["TCON"].text[0], genre)
audio["TCON"] = TCON(encoding=3, text=genre)
audio_set = True
elif name.lower().endswith(".ogg"):
try:
audio = OggVorbis(os.path.join(root, name))
except Exception, e:
print 'ERROR: Ogg Comment Error %s : %s' % (e, os.path.join(root, name))
continue
if not audio.has_key('artist'):
print 'ERROR: Vorbis comment has no "artist" key in file %s' % os.path.join(root, name)
continue
artist = audio['artist']
genre = artist_to_genre(artist[0])
if genre != None:
audio["genre"] = genre
audio_set = True
开发者ID:Tecuya,项目名称:mp3tagger,代码行数:53,代码来源:tagger.py
示例19: get_ogg_tag_info
def get_ogg_tag_info(f):
global blankstr
ret = {"file":f,"length":"0"}
try:
i = OggVorbis(f)
ret["length"] = str(i.info.length)
for k in ["artist", "album", "year", "tracknumber", "title"]:
if i.has_key(k):
ret[k] = str(i[k])
except Exception, e:
print("\r%s\rUnable to read OGG info for\n%s" %(blankstr, f))
print(str(e))
开发者ID:qingfeng,项目名称:fappy,代码行数:12,代码来源:fappy.py
示例20: CopyTags
def CopyTags(source_file, target_file):
o = OggVorbis(source_file)
m = EasyID3(target_file)
for key in ["artist", "title", "album", "date", "genre", "tracknumber"]:
if o.has_key(key):
m[key] = o[key]
m.save()
if o.has_key("discnumber"):
m = MP3(target_file)
m["TPOS"] = TPOS(encoding=3, text=o["discnumber"])
m.save()
开发者ID:tbashore,项目名称:transcoder-scripts,代码行数:13,代码来源:oggtomp3.py
注:本文中的mutagen.oggvorbis.OggVorbis类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论