use beets mediafile in favor of old music-tag library

This commit is contained in:
jbannon 2022-04-28 05:34:45 +00:00
parent d5b99a501c
commit 424a6969f5
4 changed files with 34 additions and 25 deletions

View file

@ -22,7 +22,7 @@ presets:
albumartist: "{artist}" albumartist: "{artist}"
title: "{title}" title: "{title}"
album: "{album}" album: "{album}"
tracknumber: "{track_number}" track: "{track_number}"
year: "{album_year}" year: "{album_year}"
genre: "{genre}" genre: "{genre}"

View file

@ -25,7 +25,7 @@ install_requires =
argparse==1.4.0 argparse==1.4.0
dicttoxml==1.7.4 dicttoxml==1.7.4
mergedeep==1.3.4 mergedeep==1.3.4
music-tag==0.4.3 mediafile==0.9.0
Pillow==9.1.0 Pillow==9.1.0
PyYAML==6.0 PyYAML==6.0
yt-dlp==2022.4.8 yt-dlp==2022.4.8

View file

@ -1,4 +1,4 @@
import music_tag import mediafile
from ytdl_sub.entries.entry import Entry from ytdl_sub.entries.entry import Entry
from ytdl_sub.plugins.plugin import Plugin from ytdl_sub.plugins.plugin import Plugin
@ -28,7 +28,16 @@ class MusicTagsPlugin(Plugin[MusicTagsOptions]):
""" """
Tags the entry's audio file using values defined in the metadata options Tags the entry's audio file using values defined in the metadata options
""" """
audio_file = music_tag.load_file(entry.get_download_file_path()) audio_file = mediafile.MediaFile(entry.get_download_file_path())
for tag, tag_formatter in self.plugin_options.tags.dict.items(): for tag, tag_formatter in self.plugin_options.tags.dict.items():
audio_file[tag] = self.overrides.apply_formatter(formatter=tag_formatter, entry=entry) if tag not in audio_file.fields():
# TODO: Add proper logger and warn here
print(
f"[ytld-sub: WARN] tag {tag} is not supported for {entry.ext} files. Supported "
f"tags: {', '.join(audio_file.sorted_fields())}"
)
tag_value = self.overrides.apply_formatter(formatter=tag_formatter, entry=entry)
setattr(audio_file, tag, tag_value)
audio_file.save() audio_file.save()

View file

@ -18,13 +18,13 @@
# artist: "DeLorra" # artist: "DeLorra"
# genre: "Synthwave / Electronic" # genre: "Synthwave / Electronic"
# #
#bl00dwave: bl00dwave:
# preset: "soundcloud_with_id3_tags" preset: "soundcloud_with_id3_tags"
# soundcloud: soundcloud:
# username: bl00dwave username: bl00dwave
# overrides: overrides:
# artist: "bl00dwave" artist: "bl00dwave"
# genre: "Synthwave / Electronic" genre: "Synthwave / Electronic"
# #
#tom_petty: #tom_petty:
# preset: "music_videos" # preset: "music_videos"
@ -56,16 +56,16 @@
# overrides: # overrides:
# artist: "The Gogos" # artist: "The Gogos"
recent_channel_test: #recent_channel_test:
preset: "yt_channel" # preset: "yt_channel"
ytdl_options: # ytdl_options:
break_on_reject: True # break_on_reject: True
youtube: # youtube:
channel_id: "UCsvn_Po0SmunchJYOWpOxMg" # channel_id: "UCsvn_Po0SmunchJYOWpOxMg"
after: today-13days # after: today-13days
output_options: # output_options:
output_directory: "/tmp/dunkey" # output_directory: "/tmp/dunkey"
keep_files: # keep_files:
after: today-3days # after: today-3days
overrides: # overrides:
tv_show_name: "Youtube: Dunkey" # tv_show_name: "Youtube: Dunkey"