~ubuntu-branches/debian/wheezy/quodlibet/wheezy

« back to all changes in this revision

Viewing changes to formats/mpc.py

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2009-01-30 23:55:34 UTC
  • mto: (18.1.1 squeeze) (2.1.9 sid)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: james.westby@ubuntu.com-20090130235534-45857nfsgobw4apc
Tags: upstream-2.0
ImportĀ upstreamĀ versionĀ 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2004-2005 Joe Wreschnig, Michael Urman
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License version 2 as
5
 
# published by the Free Software Foundation
6
 
#
7
 
# $Id: mpc.py 4047 2007-04-30 03:49:58Z piman $
8
 
 
9
 
import gst
10
 
 
11
 
from formats._apev2 import APEv2File
12
 
 
13
 
extensions = [".mpc", ".mp+"]
14
 
try:
15
 
    from mutagen.musepack import Musepack
16
 
except (ImportError, OSError):
17
 
    extensions = []
18
 
else:
19
 
    if gst.registry_get_default().find_plugin("musepack") is None:
20
 
        extensions = []
21
 
 
22
 
class MPCFile(APEv2File):
23
 
    format = "Musepack"
24
 
 
25
 
    def __init__(self, filename):
26
 
        audio = Musepack(filename)
27
 
        super(MPCFile, self).__init__(filename, audio)
28
 
        self["~#length"] = int(audio.info.length)
29
 
        self["~#bitrate"] = int(audio.info.bitrate)
30
 
 
31
 
        try:
32
 
            if audio.info.title_gain:
33
 
                track_g = u"%+0.2f dB" % audio.info.title_gain
34
 
                self.setdefault("replaygain_track_gain", track_g)
35
 
            if audio.info.album_gain:
36
 
                album_g = u"%+0.2f dB" % audio.info.album_gain
37
 
                self.setdefault("replaygain_album_gain", album_g)
38
 
            if audio.info.title_peak:
39
 
                track_p = unicode(audio.info.title_peak * 2)
40
 
                self.setdefault("replaygain_track_peak", track_p)
41
 
            if audio.info.album_peak:
42
 
                album_p = unicode(audio.info.album_peak * 2)
43
 
                self.setdefault("replaygain_album_peak", album_p)
44
 
        except AttributeError:
45
 
            pass
46
 
 
47
 
        self.sanitize(filename)
48
 
 
49
 
info = MPCFile