File: ape2id3.py

package info (click to toggle)
quodlibet-plugins 20060823-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 288 kB
  • ctags: 611
  • sloc: python: 3,375; makefile: 23; sh: 11
file content (34 lines) | stat: -rw-r--r-- 1,140 bytes parent folder | download | duplicates (2)
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
# Copyright 2005 Joe Wreschnig
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation
#
# $Id: ape2id3.py 3644 2006-07-16 23:11:24Z piman $

import mutagen.apev2
from formats._apev2 import APEv2File
from formats.mp3 import MP3File

from plugins.songsmenu import SongsMenuPlugin

class APEv2toID3v2(SongsMenuPlugin):
    PLUGIN_ID = "APEv2 to ID3v2"
    PLUGIN_NAME = _("APEv2 to ID3v2")
    PLUGIN_DESC = ("Convert your APEv2 tags to ID3v2 tags. This will delete "
                   "the APEv2 tags after conversion.")
    PLUGIN_ICON = 'gtk-convert'
    PLUGIN_VERSION = '0.2'

    def plugin_handles(self, songs):
        for song in songs:
            if not song.get("~filename", "").lower().endswith(".mp3"):
                return False
        return True

    def plugin_song(self, song):
        try: apesong = APEv2File(song["~filename"])
        except: return # File doesn't have an APEv2 tag
        song.update(apesong)
        mutagen.apev2.delete(song["~filename"])
        song._song.write()