1# -*- coding: utf-8 -*-
2# Copyright 2006 Joe Wreschnig
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8
9"""
10since 1.9: mutagen.m4a is deprecated; use mutagen.mp4 instead.
11since 1.31: mutagen.m4a will no longer work; any operation that could fail
12            will fail now.
13"""
14
15import warnings
16
17from mutagen import FileType, Tags, StreamInfo
18from ._util import DictProxy, MutagenError, loadfile
19
20warnings.warn(
21    "mutagen.m4a is deprecated; use mutagen.mp4 instead.",
22    DeprecationWarning)
23
24
25class error(MutagenError):
26    pass
27
28
29class M4AMetadataError(error):
30    pass
31
32
33class M4AStreamInfoError(error):
34    pass
35
36
37class M4AMetadataValueError(error):
38    pass
39
40
41__all__ = ['M4A', 'Open', 'delete', 'M4ACover']
42
43
44class M4ACover(bytes):
45
46    FORMAT_JPEG = 0x0D
47    FORMAT_PNG = 0x0E
48
49    def __new__(cls, data, imageformat=None):
50        self = bytes.__new__(cls, data)
51        if imageformat is None:
52            imageformat = M4ACover.FORMAT_JPEG
53        self.imageformat = imageformat
54        return self
55
56
57class M4ATags(DictProxy, Tags):
58
59    def load(self, atoms, fileobj):
60        raise error("deprecated")
61
62    def save(self, filename):
63        raise error("deprecated")
64
65    def delete(self, filename):
66        raise error("deprecated")
67
68    def pprint(self):
69        return u""
70
71
72class M4AInfo(StreamInfo):
73
74    bitrate = 0
75
76    def __init__(self, atoms, fileobj):
77        raise error("deprecated")
78
79    def pprint(self):
80        return u""
81
82
83class M4A(FileType):
84
85    _mimes = ["audio/mp4", "audio/x-m4a", "audio/mpeg4", "audio/aac"]
86
87    @loadfile()
88    def load(self, filething):
89        raise error("deprecated")
90
91    def add_tags(self):
92        self.tags = M4ATags()
93
94    @staticmethod
95    def score(filename, fileobj, header):
96        return 0
97
98
99Open = M4A
100
101
102def delete(filename):
103    raise error("deprecated")
104