mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-20 22:54:10 +00:00
Add support for tagging TAK files
This commit is contained in:
@@ -373,7 +373,8 @@ class File(LockableObject, Item):
|
||||
return False
|
||||
|
||||
def _info(self, metadata, file):
|
||||
metadata.length = int(file.info.length * 1000)
|
||||
if hasattr(file.info, 'length'):
|
||||
metadata.length = int(file.info.length * 1000)
|
||||
if hasattr(file.info, 'bitrate') and file.info.bitrate:
|
||||
metadata['~#bitrate'] = file.info.bitrate / 1000.0
|
||||
if hasattr(file.info, 'sample_rate') and file.info.sample_rate:
|
||||
|
||||
@@ -150,11 +150,13 @@ from picard.formats.apev2 import (
|
||||
MusepackFile,
|
||||
OptimFROGFile,
|
||||
WavPackFile,
|
||||
TAKFile,
|
||||
)
|
||||
register_format(MusepackFile)
|
||||
register_format(WavPackFile)
|
||||
register_format(OptimFROGFile)
|
||||
register_format(MonkeysAudioFile)
|
||||
register_format(TAKFile)
|
||||
|
||||
from picard.formats.vorbis import (
|
||||
FLACFile,
|
||||
|
||||
@@ -22,6 +22,7 @@ import mutagen.monkeysaudio
|
||||
import mutagen.musepack
|
||||
import mutagen.wavpack
|
||||
import mutagen.optimfrog
|
||||
import mutagenext.tak
|
||||
from picard.file import File
|
||||
from picard.metadata import Metadata
|
||||
from picard.util import encode_filename, sanitize_date
|
||||
@@ -161,3 +162,12 @@ class MonkeysAudioFile(APEv2File):
|
||||
def _info(self, metadata, file):
|
||||
super(MonkeysAudioFile, self)._info(metadata, file)
|
||||
metadata['~format'] = self.NAME
|
||||
|
||||
class TAKFile(APEv2File):
|
||||
"""TAK file."""
|
||||
EXTENSIONS = [".tak"]
|
||||
NAME = "Tom's lossless Audio Kompressor"
|
||||
_File = mutagenext.tak.TAK
|
||||
def _info(self, metadata, file):
|
||||
super(TAKFile, self)._info(metadata, file)
|
||||
metadata['~format'] = self.NAME
|
||||
|
||||
48
picard/formats/mutagenext/tak.py
Normal file
48
picard/formats/mutagenext/tak.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# Tom's lossless Audio Kompressor (TAK) reader/tagger
|
||||
#
|
||||
# Copyright 2008 Lukas Lalinsky <lalinsky@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $$
|
||||
|
||||
"""Tom's lossless Audio Kompressor streams with APEv2 tags.
|
||||
|
||||
TAK is a lossless audio compressor developed by Thomas Becker.
|
||||
|
||||
For more information, see http://wiki.hydrogenaudio.org/index.php?title=TAK
|
||||
and http://en.wikipedia.org/wiki/TAK_(audio_codec)
|
||||
"""
|
||||
|
||||
__all__ = ["TAK", "Open", "delete"]
|
||||
|
||||
from mutagen.apev2 import APEv2File, error, delete
|
||||
|
||||
class TAKHeaderError(error): pass
|
||||
|
||||
class TAKInfo(object):
|
||||
"""TAK stream information.
|
||||
|
||||
Attributes:
|
||||
(none at the moment)
|
||||
"""
|
||||
|
||||
def __init__(self, fileobj):
|
||||
header = fileobj.read(4)
|
||||
if len(header) != 4 or not header.startswith("tBaK"):
|
||||
raise TAKHeaderError("not a TAK file")
|
||||
|
||||
def pprint(self):
|
||||
return "Tom's lossless Audio Kompressor"
|
||||
|
||||
class TAK(APEv2File):
|
||||
_Info = TAKInfo
|
||||
_mimes = ["audio/x-tak"]
|
||||
|
||||
def score(filename, fileobj, header):
|
||||
return header.startswith("tBaK") + filename.lower().endswith(".tak")
|
||||
score = staticmethod(score)
|
||||
|
||||
Open = TAK
|
||||
Reference in New Issue
Block a user