Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer synced lyrics, options to allow only plain/synced #47

Merged
merged 8 commits into from
Jun 11, 2024

Conversation

jmaximusix
Copy link
Contributor

  • Prefer synced lyrics, but allow plaintext as fallback (default behaviour) (fixes No option to prefer synced, but allow plaintext lyrics #45 )
  • to not break backwards compatibility, the --allow-plain option still exists as an alias for the new (more concise) --plaintext-only
  • new --synced-only option
  • Documented behaviour of --enhanced: If no word-by-word sync is available, synced lyrics are used as a fallback. (Behaviour didn't change, but updated README for clarity)
  • if no translation is found it raises an exception (that is caught above). This is in my opinion better than checking if the translation worked later
  • small fix / enhancement: added __str__ method to LRCProvider, to avoid repeated provider.__class__.__name__()

Copy link
Owner

@moehmeni moehmeni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for huge improvement. I addressed some concerns that I hope we can discuss and fix.

@@ -120,12 +128,13 @@ def get_lrc(self, search_term: str) -> Optional[str]:
return None
body = r.json()["message"]["body"]
tracks = body["track_list"]
cmp_key = lambda t: f"{t['track']['track_name']} {t['track']['artist_name']}"
def cmp_key(t): return f"{t['track']['track_name']} {t['track']['artist_name']}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you replaced lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nothing in particular I think it got replaced automatically on save in vscode because pep8 conventions want this or something, I personally don't care, I can change it back

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, the project follows formatting of black module. Can you also run poetry run black synceldyrics before merging.

r = self._get(
"track.subtitle.get",
[("track_id", track_id), ("subtitle_format", "lrc")],
)
print(self.lang)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your're absolutely right, I accidentally left it in there from testing

@@ -11,29 +11,42 @@
from typing import List, Optional

from .providers import Deezer, Lrclib, Musixmatch, NetEase, Megalobiz, Genius
from .utils import is_lrc_valid, save_lrc_file
from .utils import Lyrics, TargetType
from .providers.base import LRCProvider

logger = logging.getLogger(__name__)


def search(
search_term: str,
allow_plain_format: bool = False,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think introducing a class as the response of the search function will break the compatibility anyway. So allow plain would be no longer necessary instead we can replace it with plaintext_only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yeah, I was unsure how you feel about it, I also think it would be cleaner to return the class, rename the "allow_plaintext" to "plaintext_only", even though it breaks compatibility.
However in the current form I tried not to break compatibility and therefore made the search function still return a string (selecting from the Lyrics class according to the preference). If you want I can quickly change that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I thought you returned the Lyrics instance . In that case I think string is simpler and doesn't break anything so all good no change needed.

@jmaximusix
Copy link
Contributor Author

uhmmm... well that's unfortunate xD
I just removed the print statement, now apparently they couldn't reach deezer?
Can you somehow restart the tests or do they only run on commits?

@moehmeni
Copy link
Owner

Seems Deezer doesn't work anymore lol. I wanted to comment out Deezer calls in search function and also put a help comment in readme but I don't know what happens if I change the main branch and your updates are based on previous version. I appreciate it if you can do it (also comment the Deezer test) so the tests pass and I will merge the changes.

@jmaximusix
Copy link
Contributor Author

jmaximusix commented Jun 11, 2024

Ok, I used black to reformat, and changed the functions back to lambdas.

Also commented out Deezer. Are we sure yet whether this broke permanently (due to an api change of theirs or sth) or if it's only temporarily down?
Edit: Just saw you opened an issue, and based on the response seems like an api change you're right

If there's anything else you want to change before merging, let me know :)

@moehmeni
Copy link
Owner

Great. Thanks again!

@moehmeni moehmeni merged commit e82d6ec into moehmeni:main Jun 11, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No option to prefer synced, but allow plaintext lyrics
2 participants