/usr/share/musiclibrarian/plugins/oggfile.py is in musiclibrarian 1.6-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # oggfile.py - read .ogg files into the library.
from musiclibrarian import genreset
import musiclibrarian.musicfile
import ogg.vorbis
class OggFile(musiclibrarian.musicfile.DictFile):
"""This class represents an Ogg file."""
def __init__(self, library, fn, cache):
self.fn=fn
if cache == None:
musiclibrarian.musicfile.DictFile.__init__(self, library, ogg.vorbis.VorbisFile(fn).comment().as_dict())
else:
musiclibrarian.musicfile.DictFile.__init__(self, library, cache)
def write_to_file(self):
"""Write the comments back to the Vorbis file."""
class FooExcept:
"""This class exists solely to work around a bug in past
versions of pyvorbis."""
def __init__(self):
pass
try:
c=ogg.vorbis.VorbisComment(self.comments)
# work around a pyvorbis bug by trashing exception information:
raise FooExcept()
except FooExcept:
pass
c.write_to(self.fn)
def get_file(self):
class VorbisWrapper:
def __init__(self, vf):
self.vf=vf
def read(self, amt=-1):
buf,amt,link=self.vf.read(amt)
if amt == 0:
return None,0,0,16,0
else:
info=self.vf.info(link)
return buf,amt,info.rate,16,info.channels
try:
return VorbisWrapper(ogg.vorbis.VorbisFile(self.fn))
except:
# Maybe it isn't present any more?
return None
def valid_genres(self):
"""All genres are valid for Vorbis files."""
return genreset.GenreSet(True)
musiclibrarian.musicfile.register_file_type('ogg', OggFile)
|