-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreTagAllMP3s.py
41 lines (30 loc) · 1.29 KB
/
reTagAllMP3s.py
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
import os
import eyed3
import argparse
from csvHandler import parse_csv_song_library
from tagMP3 import tag_mp3_file
def re_tag_all_mp3s(csv_path, mp3_directory):
eyed3.log.setLevel("ERROR")
count = 0
failed = 0
tracks = parse_csv_song_library(csv_path, mp3_directory)
for track in tracks:
album_dir = track["Sanitized Directory"]
track_file_name = track["Sanitized Song Title"] + ".mp3"
track_file_path = os.path.join(album_dir, track_file_name)
if os.path.exists(track_file_path):
artist = track["Artist Names"]
album = track["Album Title"]
title = track["Song Title"]
print(f"{artist} - {album} - {title}")
tag_mp3_file(track_file_path, artist, album, title, True)
count = count + 1
else:
failed = failed + 1
print(f"tagged {count} tracks. Failed: {failed}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Parse a CSV file and return as an array with additional columns.")
parser.add_argument("--csv_path", help="Path to the CSV file")
parser.add_argument("--library_path", help="Path to the directory containing all fo the MP3s")
args = parser.parse_args()
re_tag_all_mp3s(args.csv_path, args.library_path)