Created
February 8, 2023 23:31
-
-
Save axeldelafosse/e2f21eaff6b6392790352cabd42430bd to your computer and use it in GitHub Desktop.
Write the ID3v2.4 tag `TXXX:STYLE` to `TCON`
This file contains hidden or 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
import sys | |
import mutagen | |
def write_style_to_genre(input_path): | |
# Open the file | |
file = mutagen.File(input_path) | |
print(file.tags.pprint()) | |
# Check if the file has a STYLE tag | |
if "TXXX:STYLE" in file: | |
# Extract the style | |
style = file["TXXX:STYLE"].text[0] | |
# Print the style | |
print(style) | |
# Set the genre | |
file["TCON"] = mutagen.id3.TCON(encoding=3, text=style) | |
# Save the file | |
file.save() | |
else: | |
print("Error: The file does not have a STYLE tag.") | |
# Read the input path from the command line arguments | |
input_path = sys.argv[1] | |
# Write style to genre | |
write_style_to_genre(input_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment