tmp
This commit is contained in:
parent
d8929d3064
commit
a4524d7384
5 changed files with 31 additions and 16 deletions
|
|
@ -46,13 +46,19 @@ def update_local_library(root_dir):
|
|||
abs_path = os.path.join(root_dir, track['path'])
|
||||
match track['type']:
|
||||
case ".mp3":
|
||||
tag = eyed3.load(abs_path).tag
|
||||
if not tag:
|
||||
print(f"Invalid mp3 header {abs_path}")
|
||||
mp3track = eyed3.load(abs_path)
|
||||
if not mp3track:
|
||||
print(f"Failed to load mp3 {abs_path} using just name of the file as track name")
|
||||
track['name'] = track['path']
|
||||
else:
|
||||
track['artist'] = tag.artist
|
||||
track['name'] = tag.title
|
||||
track['album'] = tag.album
|
||||
tag = mp3track.tag
|
||||
if not tag:
|
||||
print(f"Invalid mp3 header {abs_path} using just name of the file as track name")
|
||||
track['name'] = track['path']
|
||||
else:
|
||||
track['artist'] = tag.artist
|
||||
track['name'] = tag.title
|
||||
track['album'] = tag.album
|
||||
|
||||
case ".flac":
|
||||
try:
|
||||
|
|
@ -64,10 +70,11 @@ def update_local_library(root_dir):
|
|||
if 'album' in metadata:
|
||||
track['album'] = " ".join(metadata['album'])
|
||||
except mutagen.MutagenError:
|
||||
print(f"Invalid flac header {abs_path}")
|
||||
print(f"Invalid flac header {abs_path} using just name of the file as track name")
|
||||
track['name'] = track['path']
|
||||
|
||||
save_data(new_library, "local_library")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_local_library("/mnt/main/data/music/raw")
|
||||
update_local_library("/home/auser/Music/")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue