Created
July 6, 2024 04:12
-
-
Save craftablescience/51e095a7dff2c2ce57ad39beadc5fc0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specifically created to mass-edit Ponies At Dawn artist information | |
# The Bandcamp downloader I used does not set this properly, and instead puts the artist in the filename | |
# Uploading here for my personal reference | |
# Based on https://methodmatters.github.io/editing-id3-tags-mp3-meta-data-in-python | |
from mutagen.mp3 import MP3 | |
from mutagen.easyid3 import EasyID3 | |
import glob | |
import os | |
import shutil | |
files = glob.glob("in\\*\\*.mp3") | |
for path in files: | |
path_split = path.split('\\') | |
name_split = path_split[-1].split(" - ") | |
title = name_split[1][:-4] | |
artist = name_split[0][3:] | |
if ' & ' in artist: | |
artist = '/'.join(artist.split(' & ')) | |
if ', ' in artist: | |
artist = '/'.join(artist.split(', ')) | |
new_dir = f'out\\{path_split[1]}' | |
if not os.path.exists(new_dir) and not os.path.isdir(new_dir): | |
os.mkdir(new_dir) | |
new_path = f'{new_dir}\\{name_split[0][:3]}{name_split[1]}' | |
shutil.copy2(path, new_path) | |
mp3 = MP3(new_path, ID3=EasyID3) | |
mp3['title'] = title | |
mp3['artist'] = artist | |
mp3.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment