Scripts for generating a YAML file from music files (.FLAC, .mp3) for use with Plex Meta Manager.
- Clone this repository:
git clone https://github.com/pbinspanish/music-yaml-generator
- Install mutagen.
To run the script, use python main.py
. Note that while this will likely work with on other platforms and versions, it has only been tested with Python 3.11 and on Windows 11.
root_directory
: root directory for scansave_directory
: location to save the final YAML filetrack_identifier
: how to identify the track on the album. Can betrack_number
ortrack_title
. Note that if tracks share a track number (e.g. track 1 on disc 1 and track 1 on disc 2), the second will overwrite the first. This also applies for tracks on the same album with the same name.scan_mode
: how to scan the given root directory.all
will scan every file in the directory.modified
will scan only the files modified in the given number of days inmodified_time_days
.modified_time_days
: whenscan_mode
is set tomodified
, it will scan the last X days of changes, X being the value inmodified_time_days
explicit_character
: the string to be appended to the title whenappend_explicit
is set inmatching_tags
The first level in read_tags
is the file extensions, with the dot, that will be scanned e.g. ".flac". Each file extension takes a list of tags to be read. See the mutagen documentation for more information about which tags and file types are supported.
These tags are used for matching. Like read_tags
, the first level is the file extensions. each file extension contains a list of fields used for matching music files to tracks in plex. The values of each of these fields must match a read tag in read_tags
.
album_artist
: The artist in Plex.album_title
: The title of the album in Plex.track_title
: The title of the track in Plex. Note that this is only used iftrack_identifier
is set totrack_title
.track_number
: The track number of the track in Plex. Note that this is only used iftrack_identifier
is set totrack_number
. In addition, the default track number tag in id3 files store the track number along with the total track count in the form1/13
. To pull just the track number, the script by default splits thetrack_number
tag at a/
, regardless of the set tag or file extension.append_explicit
: This is the tag to read to determine whether to append the string inexplicit_character
. Note that this assumes the tag is set to 1 when explicit. Intended for use with the ITUNESADVISORY tag.
These tags are used for modifying fields in Plex, as per the Plex Meta Manager documentation. Currently, only title
and original_artist
are supported. The values of each of these fields must match a read tag in read_tags
.
title
: Changes the title of a track in Plex. Ifappend_explicit
is used, then theexplicit_character
string will be appended to this tag.original_artist
: Changes the original_artist field in Plex. Note that this is not the album artist, used for grouping and matching, but rather a per track field.
settings:
root_directory: F:\Music
save_directory: X:\Programs\plex-meta-manager\config
track_identifier: track_number
scan_mode: modified
modified_time_days: 1
explicit_character: 🅴
read_tags:
.flac:
- ALBUMARTIST
- ALBUM
- TITLE
- TRACKNUMBER
- DISPLAY ARTIST
- ITUNESADVISORY
.mp3:
- TPE2
- TALB
- TIT2
- TRCK
- TXXX:DISPLAY ARTIST
- TXXX:ITUNESADVISORY
matching_tags:
.flac:
album_artist: ALBUMARTIST
album_title: ALBUM
track_title: TITLE
track_number: TRACKNUMBER
append_explicit: ITUNESADVISORY
.mp3:
album_artist: TPE2
album_title: TALB
track_title: TIT2
track_number: TRCK
append_explicit: TXXX:ITUNESADVISORY
modification_tags:
.flac:
title: TITLE
original_artist: DISPLAY ARTIST
.mp3:
title: TIT2
original_artist: TXXX:DISPLAY ARTIST