~ubuntu-branches/ubuntu/utopic/mutagen/utopic-proposed

« back to all changes in this revision

Viewing changes to mutagen/trueaudio.py

  • Committer: Package Import Robot
  • Author(s): Daniel T Chen
  • Date: 2013-11-27 22:10:48 UTC
  • mfrom: (8.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20131127221048-ae2f5j42ak2ox3kw
Tags: 1.22-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/control: Drop faad and oggz-tools build dependencies (in
    universe).

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
True Audio is a lossless format designed for real-time encoding and
11
11
decoding. This module is based on the documentation at
12
 
http://www.true-audio.com/TTA_Lossless_Audio_Codec_-_Format_Description
 
12
http://www.true-audio.com/TTA_Lossless_Audio_Codec\_-_Format_Description
13
13
 
14
14
True Audio files use ID3 tags.
15
15
"""
19
19
from mutagen.id3 import ID3FileType, delete
20
20
from mutagen._util import cdata
21
21
 
22
 
class error(RuntimeError): pass
23
 
class TrueAudioHeaderError(error, IOError): pass
 
22
 
 
23
class error(RuntimeError):
 
24
    pass
 
25
 
 
26
 
 
27
class TrueAudioHeaderError(error, IOError):
 
28
    pass
 
29
 
24
30
 
25
31
class TrueAudioInfo(object):
26
32
    """True Audio stream information.
27
33
 
28
34
    Attributes:
29
 
    length - audio length, in seconds
30
 
    sample_rate - audio sample rate, in Hz
 
35
 
 
36
    * length - audio length, in seconds
 
37
    * sample_rate - audio sample rate, in Hz
31
38
    """
32
39
 
33
40
    def __init__(self, fileobj, offset):
43
50
        return "True Audio, %.2f seconds, %d Hz." % (
44
51
            self.length, self.sample_rate)
45
52
 
 
53
 
46
54
class TrueAudio(ID3FileType):
47
 
    """A True Audio file."""
 
55
    """A True Audio file.
 
56
 
 
57
    :ivar info: :class:`TrueAudioInfo`
 
58
    :ivar tags: :class:`ID3 <mutagen.id3.ID3>`
 
59
    """
48
60
 
49
61
    _Info = TrueAudioInfo
50
62
    _mimes = ["audio/x-tta"]
51
63
 
 
64
    @staticmethod
52
65
    def score(filename, fileobj, header):
53
66
        return (header.startswith("ID3") + header.startswith("TTA") +
54
67
                filename.lower().endswith(".tta") * 2)
55
 
    score = staticmethod(score)
 
68
 
56
69
 
57
70
Open = TrueAudio
58
71
 
 
72
 
59
73
class EasyTrueAudio(TrueAudio):
60
 
    """Like MP3, but uses EasyID3 for tags."""
 
74
    """Like MP3, but uses EasyID3 for tags.
 
75
 
 
76
    :ivar info: :class:`TrueAudioInfo`
 
77
    :ivar tags: :class:`EasyID3 <mutagen.easyid3.EasyID3>`
 
78
    """
 
79
 
61
80
    from mutagen.easyid3 import EasyID3 as ID3
62
 
 
 
81
    ID3 = ID3