Skip to content

Commit

Permalink
Use parser choices to filter providers (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
moehmeni committed Mar 8, 2024
1 parent f79e7ca commit b108908
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ syncedlyrics "SEARCH_TERM"
| Flag | Description |
| --- | --- |
| `-o` | Path to save `.lrc` lyrics, default="{search_term}.lrc" |
| `-p` | Comma-separated list of providers to include in searching |
| `-p` | Space-separated list of providers to include in searching |
| `-l` | Language code of the translation ([ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) format) |
| `-v` | Use this flag to show the logs |
| `--allow-plain` | Return a plain text (not synced) lyrics if no LRC format was found |
Expand Down
13 changes: 9 additions & 4 deletions syncedlyrics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ def cli_handler():
parser.add_argument("search_term", help="The search term to find the track.")
parser.add_argument(
"-p",
help="Comma-separated list of providers to include in searching",
help="Providers to include in the searching (separated by space). Default: all providers",
default="",
choices=["deezer", "lrclib", "megalobiz", "musixmatch", "netease"],
nargs="+",
type=str.lower,
)
parser.add_argument(
"-l", "--lang", help="Language of the translation along with the lyrics"
Expand All @@ -32,8 +35,10 @@ def cli_handler():
action="store_true",
)
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
p = args.p.split(",") if args.p else None
lrc = search(args.search_term, args.allow_plain, args.output, p, lang=args.lang)
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
lrc = search(
args.search_term, args.allow_plain, args.output, args.p, lang=args.lang
)
if lrc:
print(lrc)

0 comments on commit b108908

Please sign in to comment.