From 2aaa7f9301ecdd5bdd21330f0e6b39e2a9c32b79 Mon Sep 17 00:00:00 2001 From: infojunkie Date: Thu, 21 Nov 2024 20:18:33 -0800 Subject: [PATCH] Add --only option as opposite of --skip --- README.md | 17 +++++++++++++---- pyproject.toml | 2 +- src/discogs_tag/cli.py | 29 +++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 56987da..28f8700 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ SYNOPSIS COMMANDS COMMAND is one of the following: + version + Return version information. + tag Tag the audio files with the given Discogs release. @@ -39,8 +42,8 @@ DESCRIPTION - The numeric portion of the above, e.g. 16215626 - A local file URI pointing to a release JSON file - The SKIP flag can take one or more of the following values, comma-separated: - artist, composer, title, position, date, subtrack, album, genre, albumartist + The SKIP and ONLY flags can take one or more of the following values, comma-separated: + artist, composer, title, position, date, subtracks, album, genre, albumartist If subtracks are skipped, subtrack titles get appended to their parent track. @@ -57,6 +60,9 @@ FLAGS -s, --skip=SKIP Type: Optional[] Default: None + -o, --only=ONLY + Type: Optional[] + Default: None NOTES You can also use flags syntax for POSITIONAL ARGUMENTS @@ -70,8 +76,8 @@ SYNOPSIS discogs-tag copy SRC DESCRIPTION - The SKIP flag can take one or more of the following values, comma-separated: - artist, composer, title, position, date, subtrack, album, genre, albumartist + The SKIP and ONLY flags can take one or more of the following values, comma-separated: + artist, composer, title, position, date, subtracks, album, genre, albumartist If subtracks are skipped, subtrack titles get appended to their parent track. @@ -88,6 +94,9 @@ FLAGS -s, --skip=SKIP Type: Optional[] Default: None + -o, --only=ONLY + Type: Optional[] + Default: None NOTES You can also use flags syntax for POSITIONAL ARGUMENTS diff --git a/pyproject.toml b/pyproject.toml index fd82e89..51b0f49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "discogs-tag" -version = "1.2.1" +version = "1.3.0" description = "An audio tagger based on Discogs metadata." authors = ["infojunkie "] repository = "https://github.com/infojunkie/discogs-tag.py" diff --git a/src/discogs_tag/cli.py b/src/discogs_tag/cli.py index 6f71362..c6ebc24 100644 --- a/src/discogs_tag/cli.py +++ b/src/discogs_tag/cli.py @@ -32,12 +32,20 @@ AUDIO_EXTENSIONS = ['flac', 'mp3'] +def version(): + """ Return version information. """ + print(json.dumps({ + 'name': __NAME__, + 'version': __VERSION__ + }, indent=4)) + def tag( release, dir='./', dry=False, ignore=False, - skip=None + skip=None, + only=None ): """Tag the audio files with the given Discogs release. @@ -46,7 +54,7 @@ def tag( - The numeric portion of the above, e.g. 16215626 - A local file URI pointing to a release JSON file - The SKIP flag can take one or more of the following values, comma-separated: + The SKIP and ONLY flags can take one or more of the following values, comma-separated: artist, composer, title, position, date, subtracks, album, genre, albumartist If subtracks are skipped, subtrack titles get appended to their parent track. @@ -63,11 +71,12 @@ def copy( dir='./', dry=False, ignore=False, - skip=None + skip=None, + only=None ): """Copy the audio tags from source to destination folders. - The SKIP flag can take one or more of the following values, comma-separated: + The SKIP and ONLY flags can take one or more of the following values, comma-separated: artist, composer, title, position, date, subtracks, album, genre, albumartist If subtracks are skipped, subtrack titles get appended to their parent track. @@ -335,13 +344,20 @@ def list_files(dir): ])) def parse_options(options): - for skip in SKIP_KEYS: - options['skip_' + skip.lower()] = False if 'skip' in options and options['skip'] is not None: + for skip in SKIP_KEYS: + options['skip_' + skip.lower()] = False if isinstance(options['skip'], str): options['skip'] = [options['skip']] for skip in options['skip']: options['skip_' + skip.lower()] = True + if 'only' in options and options['only'] is not None: + for skip in SKIP_KEYS: + options['skip_' + skip.lower()] = True + if isinstance(options['only'], str): + options['only'] = [options['only']] + for skip in options['only']: + options['skip_' + skip.lower()] = False return options def apply_metadata_track(release, track, audio, n, options): @@ -407,6 +423,7 @@ def artist_name(artist): def cli(): fire.Fire({ + 'version': version, 'tag': tag, 'copy': copy, 'rename': rename