/usr/lib/python2.7/dist-packages/mutagen/trueaudio.py is in python-mutagen 1.36-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | # -*- coding: utf-8 -*-
# Copyright (C) 2006 Joe Wreschnig
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
"""True Audio audio stream information and tags.
True Audio is a lossless format designed for real-time encoding and
decoding. This module is based on the documentation at
http://www.true-audio.com/TTA_Lossless_Audio_Codec\_-_Format_Description
True Audio files use ID3 tags.
"""
__all__ = ["TrueAudio", "Open", "delete", "EasyTrueAudio"]
from ._compat import endswith
from mutagen import StreamInfo
from mutagen.id3 import ID3FileType, delete
from mutagen._util import cdata, MutagenError, convert_error
class error(MutagenError):
pass
class TrueAudioHeaderError(error):
pass
class TrueAudioInfo(StreamInfo):
"""TrueAudioInfo()
True Audio stream information.
Attributes:
length (`float`): audio length, in seconds
sample_rate (`int`): audio sample rate, in Hz
"""
@convert_error(IOError, TrueAudioHeaderError)
def __init__(self, fileobj, offset):
"""Raises TrueAudioHeaderError"""
fileobj.seek(offset or 0)
header = fileobj.read(18)
if len(header) != 18 or not header.startswith(b"TTA"):
raise TrueAudioHeaderError("TTA header not found")
self.sample_rate = cdata.int_le(header[10:14])
samples = cdata.uint_le(header[14:18])
self.length = float(samples) / self.sample_rate
def pprint(self):
return u"True Audio, %.2f seconds, %d Hz." % (
self.length, self.sample_rate)
class TrueAudio(ID3FileType):
"""TrueAudio(filething, ID3=None)
A True Audio file.
Arguments:
filething (filething)
ID3 (mutagen.id3.ID3)
Attributes:
info (`TrueAudioInfo`)
tags (`mutagen.id3.ID3`)
"""
_Info = TrueAudioInfo
_mimes = ["audio/x-tta"]
@staticmethod
def score(filename, fileobj, header):
return (header.startswith(b"ID3") + header.startswith(b"TTA") +
endswith(filename.lower(), b".tta") * 2)
Open = TrueAudio
class EasyTrueAudio(TrueAudio):
"""EasyTrueAudio(filething, ID3=None)
Like MP3, but uses EasyID3 for tags.
Arguments:
filething (filething)
ID3 (mutagen.id3.ID3)
Attributes:
info (`TrueAudioInfo`)
tags (`mutagen.easyid3.EasyID3`)
"""
from mutagen.easyid3 import EasyID3 as ID3
ID3 = ID3
|