def setUp(self):
     self.mac399 = MonkeysAudio(os.path.join("tests", "data",
                                             "mac-399.ape"))
     self.mac396 = MonkeysAudio(os.path.join("tests", "data",
                                             "mac-396.ape"))
     self.mac390 = MonkeysAudio(os.path.join("tests", "data",
                                             "mac-390-hdr.ape"))
Exemple #2
0
 def setUp(self):
     self.mac399 = MonkeysAudio(os.path.join("tests", "data",
                                             "mac-399.ape"))
     self.mac396 = MonkeysAudio(os.path.join("tests", "data",
                                             "mac-396.ape"))
     self.mac390 = MonkeysAudio(
         os.path.join("tests", "data", "mac-390-hdr.ape"))
Exemple #3
0
 def __init__(self, filename):
     with translate_errors():
         audio = MonkeysAudio(filename)
     super(MonkeysAudioFile, self).__init__(filename, audio)
     self["~#length"] = int(audio.info.length)
     self["~#channels"] = audio.info.channels
     self.sanitize(filename)
class TMonkeysAudio(TestCase):

    def setUp(self):
        self.mac399 = MonkeysAudio(os.path.join(DATA_DIR, "mac-399.ape"))
        self.mac396 = MonkeysAudio(os.path.join(DATA_DIR, "mac-396.ape"))
        self.mac390 = MonkeysAudio(os.path.join(DATA_DIR, "mac-390-hdr.ape"))

    def test_channels(self):
        self.failUnlessEqual(self.mac399.info.channels, 2)
        self.failUnlessEqual(self.mac396.info.channels, 2)
        self.failUnlessEqual(self.mac390.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.mac399.info.sample_rate, 44100)
        self.failUnlessEqual(self.mac396.info.sample_rate, 44100)
        self.failUnlessEqual(self.mac390.info.sample_rate, 44100)

    def test_length(self):
        self.failUnlessAlmostEqual(self.mac399.info.length, 3.68, 2)
        self.failUnlessAlmostEqual(self.mac396.info.length, 3.68, 2)
        self.failUnlessAlmostEqual(self.mac390.info.length, 15.63, 2)

    def test_bits_per_sample(self):
        assert self.mac399.info.bits_per_sample == 16
        assert self.mac396.info.bits_per_sample == 16
        assert self.mac390.info.bits_per_sample == 16

    def test_version(self):
        self.failUnlessEqual(self.mac399.info.version, 3.99)
        self.failUnlessEqual(self.mac396.info.version, 3.96)
        self.failUnlessEqual(self.mac390.info.version, 3.90)

    def test_not_my_file(self):
        self.failUnlessRaises(
            MonkeysAudioHeaderError, MonkeysAudio,
            os.path.join(DATA_DIR, "empty.ogg"))
        self.failUnlessRaises(
            MonkeysAudioHeaderError, MonkeysAudio,
            os.path.join(DATA_DIR, "click.mpc"))

    def test_mime(self):
        self.failUnless("audio/x-ape" in self.mac399.mime)

    def test_pprint(self):
        self.failUnless(self.mac399.pprint())
        self.failUnless(self.mac396.pprint())
Exemple #5
0
class TMonkeysAudio(TestCase):

    def setUp(self):
        self.mac399 = MonkeysAudio(os.path.join("tests", "data",
                                                "mac-399.ape"))
        self.mac396 = MonkeysAudio(os.path.join("tests", "data",
                                                "mac-396.ape"))
        self.mac390 = MonkeysAudio(os.path.join("tests", "data",
                                                "mac-390-hdr.ape"))

    def test_channels(self):
        self.failUnlessEqual(self.mac399.info.channels, 2)
        self.failUnlessEqual(self.mac396.info.channels, 2)
        self.failUnlessEqual(self.mac390.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.mac399.info.sample_rate, 44100)
        self.failUnlessEqual(self.mac396.info.sample_rate, 44100)
        self.failUnlessEqual(self.mac390.info.sample_rate, 44100)

    def test_length(self):
        self.failUnlessAlmostEqual(self.mac399.info.length, 3.68, 2)
        self.failUnlessAlmostEqual(self.mac396.info.length, 3.68, 2)
        self.failUnlessAlmostEqual(self.mac390.info.length, 15.63, 2)

    def test_version(self):
        self.failUnlessEqual(self.mac399.info.version, 3.99)
        self.failUnlessEqual(self.mac396.info.version, 3.96)
        self.failUnlessEqual(self.mac390.info.version, 3.90)

    def test_not_my_file(self):
        self.failUnlessRaises(
            MonkeysAudioHeaderError, MonkeysAudio,
            os.path.join("tests", "data", "empty.ogg"))
        self.failUnlessRaises(
            MonkeysAudioHeaderError, MonkeysAudio,
            os.path.join("tests", "data", "click.mpc"))

    def test_mime(self):
        self.failUnless("audio/x-ape" in self.mac399.mime)

    def test_pprint(self):
        self.failUnless(self.mac399.pprint())
        self.failUnless(self.mac396.pprint())
Exemple #6
0
 def __init__(self, filename):
     with translate_errors():
         audio = MonkeysAudio(filename)
     super().__init__(filename, audio)
     self["~#length"] = int(audio.info.length)
     self["~#channels"] = audio.info.channels
     self["~#samplerate"] = audio.info.sample_rate
     if hasattr(audio.info, "bits_per_sample"):
         self["~#bitdepth"] = audio.info.bits_per_sample
     self.sanitize(filename)
Exemple #7
0
    def __init__(self, path):
        super(Track, self).__init__(path)
        self.ape = MonkeysAudio(path)
        f = self.ape

        self.title = f.get('Title')
        self.discnumber = reader.number(f.get('Disc'))
        self.tracknumber = reader.number(f.get('Track'))
        self.length = int(f.info.length)
        #self.bitrate = int(f.info.bitrate)

        self.musicbrainz_trackid = reader.value(f.get('Musicbrainz_Trackid'))
        self.genres = reader.item_to_list(f.get('Genre'))

        artist = reader.Artist()
        artist.name = f.get('Artist')
        artist.sortname = f.get('Artistsort')
        artist.musicbrainz_artistid = reader.item_to_list(f.get('Musicbrainz_Artistid'))
        self.artist = artist

        for a, i in zip(
                reader.item_to_list(f.get('Artists', [])),
                reader.item_to_list(f.get('Musicbrainz_Artistid', [])),
                ):
            artist = reader.Artist()
            artist.name = a
            artist.musicbrainz_artistid = i
            self.artists.append(artist)

        album = reader.Album()
        album.title = f.get('Album')
        album.date = f.get('Originaldate') or f.get('Year')
        album.country = f.get('Releasecountry')
        album.musicbrainz_albumid = reader.value(f.get('Musicbrainz_Albumid'))
        album.musicbrainz_releasegroupid = reader.value(f.get('Musicbrainz_Releasegroupid'))
        album.labels = reader.item_to_list(f.get('Label'))
        album.albumtypes = reader.item_to_list(f.get('MUSICBRAINZ_ALBUMTYPE'))
        album.albumstatus = reader.item_to_list(f.get('MUSICBRAINZ_ALBUMSTATUS'))

        albumartist = reader.Artist()
        albumartist.name = f.get('Album Artist') or f.get('Albumartist')
        albumartist.sortname = f.get('Albumartistsort')
        albumartist.musicbrainz_artistid = reader.item_to_list(f.get('Musicbrainz_Albumartistid'))
        album.artist = albumartist

        self.album = album
Exemple #8
0
def getTrack(filename):
    """ Return a Track created from an APE file """
    from mutagen.monkeysaudio import MonkeysAudio

    mFile = MonkeysAudio(filename)

    length = int(round(mFile.info.length))
    samplerate = int(mFile.info.sample_rate)

    try:
        trackNumber = str(mFile['Track'][0])
    except:
        trackNumber = None

    try:
        date = str(mFile['Year'][0])
    except:
        date = None

    try:
        title = str(mFile['Title'][0])
    except:
        title = None

    try:
        album = str(mFile['Album'][0])
    except:
        album = None

    try:
        artist = str(mFile['Artist'][0])
    except:
        artist = None

    try:
        genre = str(mFile['Genre'][0])
    except:
        genre = None

    return createFileTrack(filename, -1, length, samplerate, False, title,
                           album, artist, None, None, genre, trackNumber, date,
                           None)
Exemple #9
0
def get_mutagen_audio (path):
    logging.debug("GET mutagen audio" + path)
    ext = get_file_extension(path)
    audio = None
    if ext == ".flac":
        audio = FLAC(path)
    if ext == ".ape":
        audio = MonkeysAudio(path)
    if ext == ".mp3":
        audio = MP3(path, ID3=EasyID3)
    if ext == ".wv":
        audio = WavPack(path)
    if ext == ".wma":
        audio = ASF(path)
    if ext == ".ogg":
        try:
            audio = OggVorbis(path)
        except:
            from mutagen.oggtheora import OggTheora
            try:
                audio = OggTheora(path)
            except:
                from mutagen.oggflac import OggFLAC
                try:
                    audio = OggFLAC(path)
                except:
                    from mutagen.oggspeex import OggSpeex
                    try:
                        audio = OggSpeex(path)
                    except:
                        logging.error("This file in not ogg format")

    if ext == ".m4a" or ext == ".mp4" or ext == ".mkv":
        audio = MP4(path)

    return audio
Exemple #10
0
 def __init__(self, filename):
     audio = MonkeysAudio(filename)
     super(MonkeysAudioFile, self).__init__(filename, audio)
     self["~#length"] = int(audio.info.length)
     self.sanitize(filename)
 def setUp(self):
     self.mac399 = MonkeysAudio(os.path.join(DATA_DIR, "mac-399.ape"))
     self.mac396 = MonkeysAudio(os.path.join(DATA_DIR, "mac-396.ape"))
     self.mac390 = MonkeysAudio(os.path.join(DATA_DIR, "mac-390-hdr.ape"))
 def setUp(self):
     self.mac399 = MonkeysAudio(os.path.join(DATA_DIR, "mac-399.ape"))
     self.mac396 = MonkeysAudio(os.path.join(DATA_DIR, "mac-396.ape"))
     self.mac390 = MonkeysAudio(os.path.join(DATA_DIR, "mac-390-hdr.ape"))