Mercurial > public > sg101
comparison tools/sg101mp3comptool.py @ 1190:ce5a5c9cd9d8
Tweaks to MP3 comp tool
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 13 Mar 2022 13:09:37 -0500 |
parents | 83dd2db291f7 |
children |
comparison
equal
deleted
inserted
replaced
1189:83dd2db291f7 | 1190:ce5a5c9cd9d8 |
---|---|
13 DESC = """SG101 MP3 Comp Tool""" | 13 DESC = """SG101 MP3 Comp Tool""" |
14 TITLE_RE = re.compile(r'^(\d+)\s+-\s+(.+)"(.+)"$') | 14 TITLE_RE = re.compile(r'^(\d+)\s+-\s+(.+)"(.+)"$') |
15 | 15 |
16 def process_mp3(mp3, args): | 16 def process_mp3(mp3, args): |
17 title = mp3['fields']['title'] | 17 title = mp3['fields']['title'] |
18 print(f'Processing {title}...') | |
18 m = TITLE_RE.match(title) | 19 m = TITLE_RE.match(title) |
19 track_num = int(m[1]) | 20 track_num = int(m[1]) |
20 artist = m[2].strip() | 21 artist = m[2].strip() |
21 title = m[3] | 22 title = m[3] |
22 filename = mp3['fields']['file'].split('/')[-1] | 23 filename = mp3['fields']['file'].split('/')[-1] |
23 filepath = os.path.join(args.mp3_dir, filename) | 24 filepath = os.path.join(args.mp3_dir, filename) |
24 | 25 |
25 mp3file = eyed3.load(filepath) | 26 mp3file = eyed3.load(filepath) |
27 if mp3file.tag is None: | |
28 mp3file.tag = eyed3.id3.tag.Tag() | |
26 mp3file.tag.clear() | 29 mp3file.tag.clear() |
27 mp3file.tag.title = title | 30 mp3file.tag.title = title |
28 mp3file.tag.artist = artist | 31 mp3file.tag.artist = artist |
29 mp3file.tag.album = args.album | 32 mp3file.tag.album = args.album |
30 mp3file.tag.recording_date = args.recording_date | 33 mp3file.tag.recording_date = args.recording_date |