-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmp3-format-cover-type.py
More file actions
51 lines (44 loc) · 1.41 KB
/
mp3-format-cover-type.py
File metadata and controls
51 lines (44 loc) · 1.41 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pip install --upgrade --force-reinstall -r requirements.txt
import argparse
import eyed3
from pathlib import Path
parser = argparse.ArgumentParser(description='mp3 tags for Renault medianav')
parser.add_argument('path',
nargs='?',
action='store',
default='.',
help='path or mp3 files')
parser.add_argument('-preserve-id3v1',
action='store_true',
dest='preserve_id3v1',
help='preserve id3v1 tags')
args = parser.parse_args();
total = 0
for p in args.path:
p = Path(p)
if not p.exists():
continue
files = (p.is_file() and p.exists()) and [p] or p.glob('**/*.mp3')
for f in files:
audio = eyed3.load(f)
if audio is not None:
total += 1
# remove id3v1 tags (medianav conflicts???)
if not args.preserve_id3v1:
audio.tag.remove(f, version=eyed3.id3.ID3_V1, preserve_file_time=True)
# medinav shows images if type is OTHER
if audio.tag.images is not None and len(audio.tag.images) > 0:
for i in audio.tag.images:
i.description = ''
if i.picture_type is not eyed3.id3.frames.ImageFrame.OTHER:
i.picture_type = eyed3.id3.frames.ImageFrame.OTHER
# remove album artist and genre (medianav conflicts???)
audio.tag.album_artist = None
audio.tag.genre = None
audio.tag.save(preserve_file_time=True)
print(f'{f} -> ok');
else:
print(f'{f} -> error, invalid audio file');
print(f'total: {total}')