Skip to content

Commit

Permalink
Add --only option as opposite of --skip
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Nov 22, 2024
1 parent 0bdb45d commit 2aaa7f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -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
Expand All @@ -70,8 +76,8 @@ SYNOPSIS
discogs-tag copy SRC <flags>

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.

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
repository = "https://github.com/infojunkie/discogs-tag.py"
Expand Down
29 changes: 23 additions & 6 deletions src/discogs_tag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -407,6 +423,7 @@ def artist_name(artist):

def cli():
fire.Fire({
'version': version,
'tag': tag,
'copy': copy,
'rename': rename
Expand Down

0 comments on commit 2aaa7f9

Please sign in to comment.