diff options
Diffstat (limited to 'src/parse_mp4.py')
-rw-r--r-- | src/parse_mp4.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/parse_mp4.py b/src/parse_mp4.py new file mode 100644 index 0000000..3e92330 --- /dev/null +++ b/src/parse_mp4.py | |||
@@ -0,0 +1,67 @@ | |||
1 | from mutagen import mp4 | ||
2 | from mutagen.easyid3 import EasyID3 | ||
3 | |||
4 | |||
5 | class MP4Tags(mp4.MP4Tags): | ||
6 | |||
7 | fields = { | ||
8 | 'cover': 'covr', | ||
9 | 'tempo': 'tmpo', | ||
10 | 'track_num': 'trkn', | ||
11 | 'disc_num': 'disk', | ||
12 | 'is_part_of_compilation': 'cpil', | ||
13 | 'is_part_of_gapless_album': 'pgap', | ||
14 | 'is_podcast': 'pcst', | ||
15 | 'track_title': '\xa9nam', | ||
16 | 'album': '\xa9alb', | ||
17 | 'artist': '\xa9ART', | ||
18 | 'album_artist': 'aART', | ||
19 | 'composer': '\xa9wrt', | ||
20 | 'year': '\xa9day', | ||
21 | 'comment': '\xa9cmt', | ||
22 | 'description': 'desc', | ||
23 | 'purchase_date': 'purd', | ||
24 | 'grouping': '\xa9grp', | ||
25 | 'genre': '\xa9gen', | ||
26 | 'lyrics': '\xa9lyr', | ||
27 | 'podcast_url': 'purl', | ||
28 | 'podcast_episode_id': 'egid', | ||
29 | 'podcast_category': 'catg', | ||
30 | 'podcast_keyword': 'keyw', | ||
31 | 'encoded_by': '\xa9too', | ||
32 | 'copyright': 'cprt', | ||
33 | 'sort_album': 'soal', | ||
34 | 'sort_album_artist': 'soaa', | ||
35 | 'sort_artist': 'soar', | ||
36 | 'sort_title': 'sonm', | ||
37 | 'sort_composer': 'soco', | ||
38 | 'sort_show': 'sosn', | ||
39 | 'tv_show_name': 'tvsh', | ||
40 | } | ||
41 | |||
42 | @property | ||
43 | def track_number(self): | ||
44 | return self.track_num[0] | ||
45 | |||
46 | @property | ||
47 | def total_tracks(self): | ||
48 | return self.track_num[1] | ||
49 | |||
50 | @property | ||
51 | def disc_number(self): | ||
52 | return self.disc_num[0] | ||
53 | |||
54 | @property | ||
55 | def total_discs(self): | ||
56 | return self.disc_num[1] | ||
57 | |||
58 | def __getattr__(self, attr): | ||
59 | value = self[self.fields[attr]] | ||
60 | if len(value) == 1: | ||
61 | return value[0] | ||
62 | else: | ||
63 | return value | ||
64 | |||
65 | |||
66 | class MP4(mp4.MP4): | ||
67 | MP4Tags = MP4Tags | ||