Skip to content

Commit

Permalink
Merge pull request #32 from NikitaBeloglazov/main
Browse files Browse the repository at this point in the history
Add copy to clipboard flag (--clipboard) feature
  • Loading branch information
moehmeni authored May 23, 2024
2 parents 7ed855b + 0d2e0f2 commit 15a814f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 17 additions & 1 deletion syncedlyrics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
from syncedlyrics import search


def cli_handler():
"""
Console entry point handler function.
Expand All @@ -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"
)
Expand All @@ -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)
# - = - = - = -

0 comments on commit 15a814f

Please sign in to comment.