From 88e381e2b23dc44ecc80fa54945d003f0ccde538 Mon Sep 17 00:00:00 2001 From: Josef Friedrich Date: Sat, 11 Jun 2022 18:18:26 +0200 Subject: [PATCH] Add example INI file for the new configuration parser --- README.rst | 12 +++++++++--- audiorename/args.py | 22 ++++++++++++--------- audiorename/meta.py | 13 ++++++------ doc/source/cli.rst | 12 +++++++++--- example-config.ini | 48 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 example-config.ini diff --git a/README.rst b/README.rst index 841fec4..77bdeeb 100644 --- a/README.rst +++ b/README.rst @@ -66,8 +66,8 @@ Usage .. code-block:: text - usage: audiorenamer [-h] [-d] [-s FIELD_SKIP] [-v] [-E] [-r] - [-p BACKUP_FOLDER] [-B] [-C | -M | -n] [-A | -D] [-F] + usage: audiorenamer [-h] [-d] [-v] [-E] [-r] [-p BACKUP_FOLDER] [-B] + [-C | -M | -n] [-A | -D] [-s FIELD_SKIP] [-F] [-m ALBUM_MIN] [-e EXTENSION] [--genre-classical GENRE_CLASSICAL] [-k] [-S] [-c FORMAT_STRING] [-f FORMAT_STRING] @@ -623,9 +623,9 @@ Usage optional arguments: -h, --help show this help message and exit -d, --dry-run Don’t rename or copy the audio files. + -v, --version show program's version number and exit -s FIELD_SKIP, --field-skip FIELD_SKIP Skip renaming if field is empty. - -v, --version show program's version number and exit metadata actions: -E, --enrich-metadata @@ -634,6 +634,12 @@ Usage The audio file must have the tag field “mb_trackid”. The give audio file is not renamed. -r, --remap-classical + Remap some fields to fit better for classical music: + “composer” becomes “artist”, “work” becomes “album”, + from the “title” the work prefix is removed + (“Symphonie No. 9: I. Allegro” -> “I. Allegro”) and + “track” becomes the movement number. All overwritten + fields are safed in the “comments” field. rename: -p BACKUP_FOLDER, --backup-folder BACKUP_FOLDER diff --git a/audiorename/args.py b/audiorename/args.py index 5523e86..e3b37ce 100644 --- a/audiorename/args.py +++ b/audiorename/args.py @@ -248,14 +248,6 @@ def parse_args(argv): action='store_true' ) - # field_skip - parser.add_argument( - '-s', - '--field-skip', - help='Skip renaming if field is empty.', - default=False - ) - # version parser.add_argument( '-v', @@ -284,7 +276,11 @@ def parse_args(argv): metadata_actions.add_argument( '-r', '--remap-classical', - help='', + help='Remap some fields to fit better for classical music: \ + “composer” becomes “artist”, “work” becomes “album”, from the \ + “title” the work prefix is removed (“Symphonie No. 9: I. Allegro” \ + -> “I. Allegro”) and “track” becomes the movement number. All \ + overwritten fields are safed in the “comments” field.', action='store_true' ) @@ -380,6 +376,14 @@ def parse_args(argv): filters = parser.add_argument_group('filters') + # field_skip + parser.add_argument( + '-s', + '--field-skip', + help='Skip renaming if field is empty.', + default=False + ) + # album_complete filters.add_argument( '-F', diff --git a/audiorename/meta.py b/audiorename/meta.py index 67116f1..8393674 100644 --- a/audiorename/meta.py +++ b/audiorename/meta.py @@ -427,12 +427,13 @@ def enrich_metadata(self) -> None: self.mb_workhierarchy_ids = '/'.join(wh_ids) def remap_classical(self) -> None: - """Remap some fields to fit better for classical music. For example - ``composer`` becomes ``artist`` and ``work`` becomes ``album``. - All overwritten fields are safed in the ``comments`` field. No - combined properties (like ``ar_combined_composer``) are used and - therefore some code duplications are done on purpose to avoid circular - endless loops. + """Remap some fields to fit better for classical music: + ``composer`` becomes ``artist``, ``work`` becomes ``album``, from the + ``title`` the work prefix is removed (``Symphonie No. 9: I. Allegro`` + -> ``I. Allegro``) and ``track`` becomes the movement number. All + overwritten fields are safed in the ``comments`` field. No combined + properties (like ``ar_combined_composer``) are used and therefore some + code duplications are done on purpose to avoid circular endless loops. """ safe = [] diff --git a/doc/source/cli.rst b/doc/source/cli.rst index 43c4dcf..38868a6 100644 --- a/doc/source/cli.rst +++ b/doc/source/cli.rst @@ -3,8 +3,8 @@ Comande line interface .. code-block:: text - usage: audiorenamer [-h] [-d] [-s FIELD_SKIP] [-v] [-E] [-r] - [-p BACKUP_FOLDER] [-B] [-C | -M | -n] [-A | -D] [-F] + usage: audiorenamer [-h] [-d] [-v] [-E] [-r] [-p BACKUP_FOLDER] [-B] + [-C | -M | -n] [-A | -D] [-s FIELD_SKIP] [-F] [-m ALBUM_MIN] [-e EXTENSION] [--genre-classical GENRE_CLASSICAL] [-k] [-S] [-c FORMAT_STRING] [-f FORMAT_STRING] @@ -560,9 +560,9 @@ Comande line interface optional arguments: -h, --help show this help message and exit -d, --dry-run Don’t rename or copy the audio files. + -v, --version show program's version number and exit -s FIELD_SKIP, --field-skip FIELD_SKIP Skip renaming if field is empty. - -v, --version show program's version number and exit metadata actions: -E, --enrich-metadata @@ -571,6 +571,12 @@ Comande line interface The audio file must have the tag field “mb_trackid”. The give audio file is not renamed. -r, --remap-classical + Remap some fields to fit better for classical music: + “composer” becomes “artist”, “work” becomes “album”, + from the “title” the work prefix is removed + (“Symphonie No. 9: I. Allegro” -> “I. Allegro”) and + “track” becomes the movement number. All overwritten + fields are safed in the “comments” field. rename: -p BACKUP_FOLDER, --backup-folder BACKUP_FOLDER diff --git a/example-config.ini b/example-config.ini new file mode 100644 index 0000000..ab81d6b --- /dev/null +++ b/example-config.ini @@ -0,0 +1,48 @@ +[metadata actions] +enrich_metadata = False +remap_classical = False + +[rename] +backup_folder = None +best_format = None + +[rename move actions] +copy = False +move = False +no_rename = False + +[rename cleaning actions] +backup = False +delete = False + +[filters] +album_complete = False +album_min = False +extension = False +genre_classical = False +field_skip = False + +[formats] +classical = False +shell-friendly = False +no_soundtrack = False + +[format strings] +compilation = False +format = False +soundtrack = False +format-classical = False + +[output] +color = False +no-color = False +debug = False +job-info = False +mb-track-listing = False +one-line = False +stats = False +verbose = False + +[target] +source_as_target = False +target = False