diff --git a/README.md b/README.md index 5303ed3..70a87f4 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,10 @@ syncedlyrics "SEARCH_TERM" | Flag | Description | | --- | --- | | `-o` | Path to save `.lrc` lyrics, default="{search_term}.lrc" | +| `-с` | Copies lyrics to clipboard. Uses [clipman](https://github.com/NikitaBeloglazov/clipman) module | | `-p` | Space-separated list of [providers](#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 | +| `-v` | Use this flag to show the logs | | `--allow-plain` | Return a plain text (not synced) lyrics if no LRC format was found | | `--enhanced` | Return an [Enhanced](https://en.wikipedia.org/wiki/LRC_(file_format)#A2_extension:_word_time_tag) (word-level karaoke) format diff --git a/pyproject.toml b/pyproject.toml index d40ca5f..9c89559 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ python = ">=3.8" requests = "^2.31.0" beautifulsoup4 = "^4.12.3" rapidfuzz = "^3.6.2" +clipman = "^3.2.3" [tool.poetry.scripts] syncedlyrics = "syncedlyrics.cli:cli_handler" diff --git a/syncedlyrics/cli.py b/syncedlyrics/cli.py index b91b0e5..78c754f 100644 --- a/syncedlyrics/cli.py +++ b/syncedlyrics/cli.py @@ -2,7 +2,6 @@ import logging from syncedlyrics import search - def cli_handler(): """ Console entry point handler function. @@ -26,6 +25,9 @@ def cli_handler(): parser.add_argument( "-o", "--output", help="Path to save '.lrc' lyrics", default="{search_term}.lrc" ) + parser.add_argument( + "-c", "--clipboard", help="Copies lyrics to clipboard after finish", action="store_true" + ) parser.add_argument( "-v", "--verbose", help="Use this flag to show the logs", action="store_true" ) @@ -52,3 +54,17 @@ def cli_handler(): ) if lrc: print(lrc) + + # = - Adds copy to clipboard (--copy) flag support. + if lrc and args.clipboard: + import clipman + try: + clipman.init() + clipman.set(lrc) + print("\n\n(Copied to clipboard succefully)") + + except clipman.exceptions.ClipmanBaseException as e: + print("Some clipboard error was ocurred. If you experience any issues with it, please see https://github.com/NikitaBeloglazov/clipman.") + print("\n\nTraceback:") + print(e) + # - = - = - = -