~qioeujqioejqioe-deactivatedaccount/exaile/missing-signals

« back to all changes in this revision

Viewing changes to xl/media.py

  • Committer: synic
  • Date: 2006-11-17 23:52:38 UTC
  • Revision ID: vcs-imports@canonical.com-20061117235238-iyu717r4teh3dju7
added optional wmainfo support to test and see if it's a viable and faster
option for reading .wma tags (thanks irielion)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
pygst.require("0.10")
27
27
import gst, gst.interfaces, gobject
28
28
 
 
29
# for wmainfo support
 
30
try:
 
31
    import lib.wmainfo
 
32
    WMAINFO_AVAIL = True
 
33
except ImportError: 
 
34
    WMAINFO_AVIAL = False
 
35
 
29
36
# FORMAT and SUPPORTED_MEDIA are set up at the end of this file
30
37
FORMAT = dict()
31
38
exaile_instance = None
1144
1151
 
1145
1152
        Track.write_tag(self, db)
1146
1153
 
 
1154
class WMATrack(Track):
 
1155
    def __init__(self, *args):
 
1156
        """
 
1157
            Initializes the track
 
1158
        """
 
1159
        Track.__init__(self, *args)
 
1160
 
 
1161
    def get_tag(self, inf, name):
 
1162
        if inf.tags.has_key(name):
 
1163
            return inf.tags[name]
 
1164
        else:
 
1165
            return ''
 
1166
 
 
1167
    def read_tag(self, db=None):
 
1168
        inf = lib.wmainfo.WmaInfo(self.loc)
 
1169
 
 
1170
        self.length = inf.info["playtime_seconds"]
 
1171
        self.bitrate = inf.info["max_bitrate"]
 
1172
        self.artist = self.get_tag(inf, 'Author')
 
1173
        self.album = self.get_tag(inf, 'AlbumTitle')
 
1174
        self.title = self.get_tag(inf, 'Title') 
 
1175
        self.genre = ""
 
1176
        self.track = self.get_tag(inf, 'TrackNumber')
 
1177
        self.year = self.get_tag(inf, 'Year')
 
1178
 
 
1179
    def write_tag(self, db=None):
 
1180
        raise MetaIOException("Track %s: writing metadata to this filetype is"
 
1181
            " not currently supported." % self.loc)
 
1182
 
1147
1183
# sets up the formats dict
1148
1184
for format in ('.mpc', '.m4a', '.aac', '.m4b', '.wma'):
1149
1185
    FORMAT[format] = GSTTrack
1150
1186
FORMAT['.flac'] = FLACTrack
1151
1187
FORMAT['.ogg'] = OGGTrack
1152
1188
FORMAT['.mp3'] = MP3Track
 
1189
if WMAINFO_AVAIL:
 
1190
    FORMAT['.wma'] = WMATrack
1153
1191
SUPPORTED_MEDIA = FORMAT.keys()