Ejemplo n.º 1
0
 def test_ignore_id3(self):
     id3 = ID3()
     id3.add(TIT2(encoding=0, text='id3 title'))
     id3.save(self.NEW)
     f = Musepack(self.NEW)
     f['title'] = 'apev2 title'
     f.save()
     id3 = ID3(self.NEW)
     self.failUnlessEqual(id3['TIT2'], 'id3 title')
     f = Musepack(self.NEW)
     self.failUnlessEqual(f['title'], 'apev2 title')
Ejemplo n.º 2
0
 def test_ignore_id3(self):
     id3 = ID3()
     id3.add(TIT2(encoding=0, text="id3 title"))
     id3.save(self.NEW)
     f = Musepack(self.NEW)
     f["title"] = "apev2 title"
     f.save()
     id3 = ID3(self.NEW)
     self.failUnlessEqual(id3["TIT2"], "id3 title")
     f = Musepack(self.NEW)
     self.failUnlessEqual(f["title"], "apev2 title")
Ejemplo n.º 3
0
    def __init__(self, filename):
        with translate_errors():
            audio = Musepack(filename)

        super(MPCFile, self).__init__(filename, audio)
        self["~#length"] = audio.info.length
        self["~#bitrate"] = int(audio.info.bitrate / 1000)
        self["~#channels"] = audio.info.channels
        self["~#samplerate"] = audio.info.sample_rate

        version = audio.info.version
        self["~codec"] = u"%s SV%d" % (self.format, version)

        try:
            if audio.info.title_gain:
                track_g = u"%+0.2f dB" % audio.info.title_gain
                self.setdefault("replaygain_track_gain", track_g)
            if audio.info.album_gain:
                album_g = u"%+0.2f dB" % audio.info.album_gain
                self.setdefault("replaygain_album_gain", album_g)
            if audio.info.title_peak:
                track_p = str(audio.info.title_peak * 2)
                self.setdefault("replaygain_track_peak", track_p)
            if audio.info.album_peak:
                album_p = str(audio.info.album_peak * 2)
                self.setdefault("replaygain_album_peak", album_p)
        except AttributeError:
            pass

        self.sanitize(filename)
Ejemplo n.º 4
0
def getTrack(filename):
    """ Return a Track created from an mpc file """
    from mutagen.musepack import Musepack

    mpcFile = Musepack(filename)

    length = int(round(mpcFile.info.length))
    bitrate = int(mpcFile.info.bitrate * 1000)
    samplerate = int(mpcFile.info.sample_rate)

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

    try:
        discNumber = str(mpcFile['Discnumber'])
    except:
        discNumber = None

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

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

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

    try:
        musicbrainzId = str(mpcFile['MUSICBRAINZ_TRACKID'])
    except:
        musicbrainzId = None

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

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

    try:
        albumArtist = str(mpcFile['Album Artist'])
    except:
        albumArtist = None

    return createFileTrack(filename, bitrate, length, samplerate, False, title,
                           album, artist, albumArtist, musicbrainzId, genre,
                           trackNumber, date, discNumber)
Ejemplo n.º 5
0
 def __init__(self, file, threshold=60, duration_distance_threshold=10000):
     self.file = file
     self.threshold = threshold
     self.ddt = duration_distance_threshold
     self.cleaner = re.compile(r"[^A-Za-z0-9 ]").sub
     try:
         self.audio = MP3(file, ID3=EasyID3)
     except:
         try:
             self.audio = FLAC(file)
         except:
             try:
                 self.audio = OggVorbis(file)
             except:
                 try:
                     self.audio = OggFLAC(file)
                 except:
                     try:
                         self.audio = OggTheora(file)
                     except:
                         try:
                             self.audio = APEv2(file)
                         except:
                             try:
                                 self.audio = ASF(file)
                             except:
                                 try:
                                     self.audio = MP4(file)
                                 except:
                                     try:
                                         self.audio = Musepack(file)
                                     except:
                                         try:
                                             self.audio = TrueAudio(file)
                                         except:
                                             try:
                                                 self.audio = WavPack(file)
                                             except:
                                                 raise FileTypeException(
                                                     'Unknown file type, no metadata, or file not found.'
                                                 )
     try:
         [title] = self.audio['title']
         self.title = self.__clean_literal(str(title))
     except:
         self.title = None
     try:
         [artist] = self.audio['artist']
         self.artist = self.__clean_literal(str(artist))
     except:
         self.artist = None
     try:
         [album] = self.audio['album']
         self.album = self.__clean_literal(str(album))
     except:
         self.album = None
     self.mbzQuery()
Ejemplo n.º 6
0
class TMusepack(TestCase):
    uses_mmap = False

    def setUp(self):
        self.sv7 = Musepack(os.path.join("tests", "data", "click.mpc"))
        self.sv5 = Musepack(os.path.join("tests", "data", "sv5_header.mpc"))
        self.sv4 = Musepack(os.path.join("tests", "data", "sv4_header.mpc"))

    def test_bad_header(self):
        self.failUnlessRaises(
            MusepackHeaderError,
            Musepack, os.path.join("tests", "data", "almostempty.mpc"))

    def test_channels(self):
        self.failUnlessEqual(self.sv7.info.channels, 2)
        self.failUnlessEqual(self.sv5.info.channels, 2)
        self.failUnlessEqual(self.sv4.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.sv7.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv5.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv4.info.sample_rate, 44100)

    def test_bitrate(self):
        self.failUnlessEqual(self.sv7.info.bitrate, 195)
        self.failUnlessEqual(self.sv5.info.bitrate, 0)
        self.failUnlessEqual(self.sv4.info.bitrate, 0)

    def test_length(self):
        self.failUnlessAlmostEqual(self.sv7.info.length, 0.07, 2)
        self.failUnlessAlmostEqual(self.sv5.info.length, 26.3, 1)
        self.failUnlessAlmostEqual(self.sv4.info.length, 26.3, 1)

    def test_gain(self):
        self.failUnlessAlmostEqual(self.sv7.info.title_gain, 9.27, 6)
        self.failUnlessAlmostEqual(self.sv7.info.title_peak, 0.1149, 4)
        self.failUnlessEqual(self.sv7.info.title_gain, self.sv7.info.album_gain)
        self.failUnlessEqual(self.sv7.info.title_peak, self.sv7.info.album_peak)
        self.failUnlessRaises(AttributeError, getattr, self.sv5, 'title_gain')

    def test_not_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "empty.ogg"))
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "emptyfile.mp3"))

    def test_almost_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, MusepackInfo, StringIO("MP+" + "\x00" * 100))

    def test_pprint(self):
        self.sv7.pprint()
        self.sv5.pprint()
        self.sv4.pprint()

    def test_mime(self):
        self.failUnless("audio/x-musepack" in self.sv7.mime)
Ejemplo n.º 7
0
class TMusepack(TestCase):
    uses_mmap = False

    def setUp(self):
        self.sv7 = Musepack(os.path.join("tests", "data", "click.mpc"))
        self.sv5 = Musepack(os.path.join("tests", "data", "sv5_header.mpc"))
        self.sv4 = Musepack(os.path.join("tests", "data", "sv4_header.mpc"))

    def test_bad_header(self):
        self.failUnlessRaises(
            MusepackHeaderError,
            Musepack, os.path.join("tests", "data", "almostempty.mpc"))

    def test_channels(self):
        self.failUnlessEqual(self.sv7.info.channels, 2)
        self.failUnlessEqual(self.sv5.info.channels, 2)
        self.failUnlessEqual(self.sv4.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.sv7.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv5.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv4.info.sample_rate, 44100)

    def test_bitrate(self):
        self.failUnlessEqual(self.sv7.info.bitrate, 195)
        self.failUnlessEqual(self.sv5.info.bitrate, 0)
        self.failUnlessEqual(self.sv4.info.bitrate, 0)

    def test_length(self):
        self.failUnlessAlmostEqual(self.sv7.info.length, 0.07, 2)
        self.failUnlessAlmostEqual(self.sv5.info.length, 26.3, 1)
        self.failUnlessAlmostEqual(self.sv4.info.length, 26.3, 1)

    def test_gain(self):
        self.failUnlessAlmostEqual(self.sv7.info.title_gain, 9.27, 6)
        self.failUnlessAlmostEqual(self.sv7.info.title_peak, 0.1149, 4)
        self.failUnlessEqual(self.sv7.info.title_gain, self.sv7.info.album_gain)
        self.failUnlessEqual(self.sv7.info.title_peak, self.sv7.info.album_peak)
        self.failUnlessRaises(AttributeError, getattr, self.sv5, 'title_gain')

    def test_not_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "empty.ogg"))
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "emptyfile.mp3"))

    def test_almost_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, MusepackInfo, StringIO("MP+" + "\x00" * 100))

    def test_pprint(self):
        self.sv7.pprint()
        self.sv5.pprint()
        self.sv4.pprint()

    def test_mime(self):
        self.failUnless("audio/x-musepack" in self.sv7.mime)
Ejemplo n.º 8
0
    def __init__(self, path):
        super(Track, self).__init__(path)
        self.mpc = Musepack(path)
        f = self.mpc

        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_artistids = 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
Ejemplo n.º 9
0
 def test_ignore_id3(self):
     id3 = ID3()
     id3.add(TIT2(encoding=0, text='id3 title'))
     id3.save(self.filename)
     f = Musepack(self.filename)
     f['title'] = 'apev2 title'
     f.save()
     id3 = ID3(self.filename)
     self.failUnlessEqual(id3['TIT2'], 'id3 title')
     f = Musepack(self.filename)
     self.failUnlessEqual(f['title'], 'apev2 title')
Ejemplo n.º 10
0
    def __init__(self, filename):
        audio = Musepack(filename)
        super(MPCFile, self).__init__(filename, audio)
        self["~#length"] = int(audio.info.length)
        self["~#bitrate"] = int(audio.info.bitrate / 1000)

        try:
            if audio.info.title_gain:
                track_g = u"%+0.2f dB" % audio.info.title_gain
                self.setdefault("replaygain_track_gain", track_g)
            if audio.info.album_gain:
                album_g = u"%+0.2f dB" % audio.info.album_gain
                self.setdefault("replaygain_album_gain", album_g)
            if audio.info.title_peak:
                track_p = unicode(audio.info.title_peak * 2)
                self.setdefault("replaygain_track_peak", track_p)
            if audio.info.album_peak:
                album_p = unicode(audio.info.album_peak * 2)
                self.setdefault("replaygain_album_peak", album_p)
        except AttributeError:
            pass

        self.sanitize(filename)
Ejemplo n.º 11
0
 def setUp(self):
     self.sv8 = Musepack(os.path.join(DATA_DIR, "sv8_header.mpc"))
     self.sv7 = Musepack(os.path.join(DATA_DIR, "click.mpc"))
     self.sv5 = Musepack(os.path.join(DATA_DIR, "sv5_header.mpc"))
     self.sv4 = Musepack(os.path.join(DATA_DIR, "sv4_header.mpc"))
Ejemplo n.º 12
0
class TMusepack(TestCase):
    def setUp(self):
        self.sv8 = Musepack(os.path.join(DATA_DIR, "sv8_header.mpc"))
        self.sv7 = Musepack(os.path.join(DATA_DIR, "click.mpc"))
        self.sv5 = Musepack(os.path.join(DATA_DIR, "sv5_header.mpc"))
        self.sv4 = Musepack(os.path.join(DATA_DIR, "sv4_header.mpc"))

    def test_bad_header(self):
        self.failUnlessRaises(MusepackHeaderError, Musepack,
                              os.path.join(DATA_DIR, "almostempty.mpc"))

    def test_channels(self):
        self.failUnlessEqual(self.sv8.info.channels, 2)
        self.failUnlessEqual(self.sv7.info.channels, 2)
        self.failUnlessEqual(self.sv5.info.channels, 2)
        self.failUnlessEqual(self.sv4.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.sv8.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv7.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv5.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv4.info.sample_rate, 44100)

    def test_bitrate(self):
        self.failUnlessEqual(self.sv8.info.bitrate, 609)
        self.failUnlessEqual(self.sv7.info.bitrate, 194530)
        self.failUnlessEqual(self.sv5.info.bitrate, 39)
        self.failUnlessEqual(self.sv4.info.bitrate, 39)

    def test_length(self):
        self.failUnlessAlmostEqual(self.sv8.info.length, 1.49, 1)
        self.failUnlessAlmostEqual(self.sv7.info.length, 0.07, 2)
        self.failUnlessAlmostEqual(self.sv5.info.length, 26.3, 1)
        self.failUnlessAlmostEqual(self.sv4.info.length, 26.3, 1)

    def test_gain(self):
        self.failUnlessAlmostEqual(self.sv8.info.title_gain, -4.668, 3)
        self.failUnlessAlmostEqual(self.sv8.info.title_peak, 0.5288, 3)
        self.failUnlessEqual(self.sv8.info.title_gain,
                             self.sv8.info.album_gain)
        self.failUnlessEqual(self.sv8.info.title_peak,
                             self.sv8.info.album_peak)
        self.failUnlessAlmostEqual(self.sv7.info.title_gain, 9.27, 6)
        self.failUnlessAlmostEqual(self.sv7.info.title_peak, 0.1149, 4)
        self.failUnlessEqual(self.sv7.info.title_gain,
                             self.sv7.info.album_gain)
        self.failUnlessEqual(self.sv7.info.title_peak,
                             self.sv7.info.album_peak)
        self.failUnlessRaises(AttributeError, getattr, self.sv5, 'title_gain')

    def test_not_my_file(self):
        self.failUnlessRaises(MusepackHeaderError, Musepack,
                              os.path.join(DATA_DIR, "empty.ogg"))
        self.failUnlessRaises(MusepackHeaderError, Musepack,
                              os.path.join(DATA_DIR, "emptyfile.mp3"))

    def test_almost_my_file(self):
        self.failUnlessRaises(MusepackHeaderError, MusepackInfo,
                              cBytesIO(b"MP+" + b"\x00" * 32))
        self.failUnlessRaises(MusepackHeaderError, MusepackInfo,
                              cBytesIO(b"MP+" + b"\x00" * 100))
        self.failUnlessRaises(MusepackHeaderError, MusepackInfo,
                              cBytesIO(b"MPCK" + b"\x00" * 100))

    def test_pprint(self):
        self.sv8.pprint()
        self.sv7.pprint()
        self.sv5.pprint()
        self.sv4.pprint()

    def test_mime(self):
        self.failUnless("audio/x-musepack" in self.sv7.mime)

    def test_zero_padded_sh_packet(self):
        # https://github.com/quodlibet/mutagen/issues/198
        data = (b"MPCKSH\x10\x95 Q\xa2\x08\x81\xb8\xc9T\x00\x1e\x1b"
                b"\x00RG\x0c\x01A\xcdY\x06?\x80Z\x06EI")

        fileobj = cBytesIO(data)
        info = MusepackInfo(fileobj)
        self.assertEqual(info.channels, 2)
        self.assertEqual(info.samples, 3024084)
Ejemplo n.º 13
0
 def _save_db_to_musepack(self, pathSong, dbrating, dbcount):
     audio = Musepack(pathSong)
     self._save_db_to_dict_tags(audio, 'FMPS_RATING', 'FMPS_PLAYCOUNT',
                                unicode, dbrating, dbcount)
Ejemplo n.º 14
0
 def setUp(self):
     self.sv7 = Musepack(os.path.join("tests", "data", "click.mpc"))
     self.sv5 = Musepack(os.path.join("tests", "data", "sv5_header.mpc"))
     self.sv4 = Musepack(os.path.join("tests", "data", "sv4_header.mpc"))
Ejemplo n.º 15
0
 def _restore_db_from_musepack(self, pathSong):
     audio = Musepack(pathSong)
     return self._restore_db_from_dict_tags('FMPS_RATING', 'FMPS_PLAYCOUNT',
                                            audio)
Ejemplo n.º 16
0
class TMusepack(TestCase):

    def setUp(self):
        self.sv8 = Musepack(os.path.join("tests", "data", "sv8_header.mpc"))
        self.sv7 = Musepack(os.path.join("tests", "data", "click.mpc"))
        self.sv5 = Musepack(os.path.join("tests", "data", "sv5_header.mpc"))
        self.sv4 = Musepack(os.path.join("tests", "data", "sv4_header.mpc"))

    def test_bad_header(self):
        self.failUnlessRaises(
            MusepackHeaderError,
            Musepack, os.path.join("tests", "data", "almostempty.mpc"))

    def test_channels(self):
        self.failUnlessEqual(self.sv8.info.channels, 2)
        self.failUnlessEqual(self.sv7.info.channels, 2)
        self.failUnlessEqual(self.sv5.info.channels, 2)
        self.failUnlessEqual(self.sv4.info.channels, 2)

    def test_sample_rate(self):
        self.failUnlessEqual(self.sv8.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv7.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv5.info.sample_rate, 44100)
        self.failUnlessEqual(self.sv4.info.sample_rate, 44100)

    def test_bitrate(self):
        self.failUnlessEqual(self.sv8.info.bitrate, 609)
        self.failUnlessEqual(self.sv7.info.bitrate, 194530)
        self.failUnlessEqual(self.sv5.info.bitrate, 39)
        self.failUnlessEqual(self.sv4.info.bitrate, 39)

    def test_length(self):
        self.failUnlessAlmostEqual(self.sv8.info.length, 1.49, 1)
        self.failUnlessAlmostEqual(self.sv7.info.length, 0.07, 2)
        self.failUnlessAlmostEqual(self.sv5.info.length, 26.3, 1)
        self.failUnlessAlmostEqual(self.sv4.info.length, 26.3, 1)

    def test_gain(self):
        self.failUnlessAlmostEqual(self.sv8.info.title_gain, -4.668, 3)
        self.failUnlessAlmostEqual(self.sv8.info.title_peak, 0.5288, 3)
        self.failUnlessEqual(
            self.sv8.info.title_gain, self.sv8.info.album_gain)
        self.failUnlessEqual(
            self.sv8.info.title_peak, self.sv8.info.album_peak)
        self.failUnlessAlmostEqual(self.sv7.info.title_gain, 9.27, 6)
        self.failUnlessAlmostEqual(self.sv7.info.title_peak, 0.1149, 4)
        self.failUnlessEqual(
            self.sv7.info.title_gain, self.sv7.info.album_gain)
        self.failUnlessEqual(
            self.sv7.info.title_peak, self.sv7.info.album_peak)
        self.failUnlessRaises(AttributeError, getattr, self.sv5, 'title_gain')

    def test_not_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "empty.ogg"))
        self.failUnlessRaises(
            MusepackHeaderError, Musepack,
            os.path.join("tests", "data", "emptyfile.mp3"))

    def test_almost_my_file(self):
        self.failUnlessRaises(
            MusepackHeaderError, MusepackInfo, cBytesIO(b"MP+" + b"\x00" * 32))
        self.failUnlessRaises(
            MusepackHeaderError,
            MusepackInfo,
            cBytesIO(b"MP+" + b"\x00" * 100))
        self.failUnlessRaises(
            MusepackHeaderError,
            MusepackInfo,
            cBytesIO(b"MPCK" + b"\x00" * 100))

    def test_pprint(self):
        self.sv8.pprint()
        self.sv7.pprint()
        self.sv5.pprint()
        self.sv4.pprint()

    def test_mime(self):
        self.failUnless("audio/x-musepack" in self.sv7.mime)

    def test_zero_padded_sh_packet(self):
        # https://bitbucket.org/lazka/mutagen/issue/198
        data = (b"MPCKSH\x10\x95 Q\xa2\x08\x81\xb8\xc9T\x00\x1e\x1b"
                b"\x00RG\x0c\x01A\xcdY\x06?\x80Z\x06EI")

        fileobj = cBytesIO(data)
        info = MusepackInfo(fileobj)
        self.assertEqual(info.channels, 2)
        self.assertEqual(info.samples, 3024084)
Ejemplo n.º 17
0
 def setUp(self):
     self.sv8 = Musepack(os.path.join(DATA_DIR, "sv8_header.mpc"))
     self.sv7 = Musepack(os.path.join(DATA_DIR, "click.mpc"))
     self.sv5 = Musepack(os.path.join(DATA_DIR, "sv5_header.mpc"))
     self.sv4 = Musepack(os.path.join(DATA_DIR, "sv4_header.mpc"))
Ejemplo n.º 18
0
    def cleanAllTags(self, db, element, path_normalizado):
        """ Method to clean all rating and playcount tags from the file"""
        try:
            # Get the audio tagging format of the current element
            format = self._check_recognized_format(path_normalizado)
            if format is None:
                raise Exception("Unrecognized format")
            else:
                needsave = False
                if format == "id3v2":
                    audio = ID3(path_normalizado)
                    if audio.has_key('POPM'):
                        audio.delall('POPM')
                        needsave = True
                    if audio.has_key('PCNT'):
                        audio.delall('PCNT')
                        needsave = True
                    if audio.has_key(u'TXXX:FMPS_Rating'):
                        audio.delall(u'TXXX:FMPS_Rating')
                        needsave = True
                    if audio.has_key(u'TXXX:FMPS_Playcount'):
                        audio.delall(u'TXXX:FMPS_Playcount')
                        needsave = True

                elif format == "oggvorbis":
                    audio = OggVorbis(path_normalizado)
                    if audio.has_key('FMPS_RATING'):
                        del audio['FMPS_RATING']
                        needsave = True
                    if audio.has_key('FMPS_PLAYCOUNT'):
                        del audio['FMPS_PLAYCOUNT']
                        needsave = True

                elif format == "flac":
                    audio = FLAC(path_normalizado)
                    if audio.has_key('FMPS_RATING'):
                        del audio['FMPS_RATING']
                        needsave = True
                    if audio.has_key('FMPS_PLAYCOUNT'):
                        del audio['FMPS_PLAYCOUNT']
                        needsave = True

                elif format == "mp4":
                    audio = MP4(path_normalizado)
                    if audio.has_key('----:com.apple.iTunes:FMPS_Rating'):
                        del audio['----:com.apple.iTunes:FMPS_Rating']
                        needsave = True
                    if audio.has_key('----:com.apple.iTunes:FMPS_Playcount'):
                        del audio['----:com.apple.iTunes:FMPS_Playcount']
                        needsave = True

                elif format == "musepack":
                    audio = Musepack(path_normalizado)
                    if audio.has_key('FMPS_RATING'):
                        del audio['FMPS_RATING']
                        needsave = True
                    if audio.has_key('FMPS_PLAYCOUNT'):
                        del audio['FMPS_PLAYCOUNT']
                        needsave = True

                elif format == "oggspeex":
                    audio = OggSpeex(path_normalizado)
                    if audio.has_key('FMPS_RATING'):
                        del audio['FMPS_RATING']
                        needsave = True
                    if audio.has_key('FMPS_PLAYCOUNT'):
                        del audio['FMPS_PLAYCOUNT']
                        needsave = True

                if needsave:
                    audio.save()
                    self.num_cleaned += 1
                else:
                    self.num_already_done += 1

        except Exception, e:
            self.num_failed += 1
            print(e, path_normalizado)
Ejemplo n.º 19
0
 def setUp(self):
     self.sv7 = Musepack(os.path.join("tests", "data", "click.mpc"))
     self.sv5 = Musepack(os.path.join("tests", "data", "sv5_header.mpc"))
     self.sv4 = Musepack(os.path.join("tests", "data", "sv4_header.mpc"))