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

Added Lyrics w. Timestamps #662

Closed
wants to merge 12 commits into from
Closed

Conversation

heinrich26
Copy link
Contributor

Added get_lyrics_with_timestamps to get lyrics with timestamps. The Method doesn't try to parse the response as normal lyrics, if no lyrics with timestamps are returned. (could be changed to do so tho, the format is the same)

Added `get_lyrics_with_timestamps` to get lyrics with timestamps.
The Method doesn't try to parse the response as normal lyrics, if no lyrics with timestamps are returned. (could be changed to do so tho, the format is the same)
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 97.59036% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.01%. Comparing base (db732f2) to head (2e1e89f).

Files with missing lines Patch % Lines
ytmusicapi/mixins/browsing.py 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #662      +/-   ##
==========================================
+ Coverage   94.88%   95.01%   +0.12%     
==========================================
  Files          38       40       +2     
  Lines        2289     2348      +59     
==========================================
+ Hits         2172     2231      +59     
  Misses        117      117              
Flag Coverage Δ
unittests 95.01% <97.59%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@sigma67 sigma67 left a comment

Choose a reason for hiding this comment

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

Hi @heinrich26 , pretty cool that you were able to make this work!

I take it you're basically emulating the mobile client to fetch the timed data? Since you're modifying the client info.

Could we replace the previous get_lyrics with this? I wouldn't want to have two methods for the same purpose in the API if one provides a superset of information.

Finally, to get this merged:

  • please ensure the linters pass
  • please add a test for the function

@heinrich26
Copy link
Contributor Author

heinrich26 commented Oct 11, 2024 via email

Copy link
Owner

@sigma67 sigma67 left a comment

Choose a reason for hiding this comment

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

Thanks, looks much better! :)

As a general rule of thumb: Don't change more than necessary in a single PR. It makes it harder for the maintainer to review the changes (more time consuming), and harder to trace back potential future issues to specific PRs. It will also prolong the time it takes for the PR to get merged.

Note for this review: Please don't resolve threads, I will do so myself after verifying the changes

@@ -204,7 +206,7 @@ def search(
if filter and "playlists" in filter:
filter = "playlists"
elif scope == scopes[1]:
filter = scopes[1]
filter = scopes[1] # type:ignore
Copy link
Owner

Choose a reason for hiding this comment

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

please undo all changes to this file

ytmusicapi/mixins/uploads.py Outdated Show resolved Hide resolved
@@ -181,7 +181,7 @@ def __init__(
try:
cookie = self.base_headers.get("cookie")
self.sapisid = sapisid_from_cookie(cookie)
self.origin = self.base_headers.get("origin", self.base_headers.get("x-origin"))
self.origin = cast(str, self.base_headers.get("origin", self.base_headers.get("x-origin")))
Copy link
Owner

Choose a reason for hiding this comment

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

Please undo changes to this file

@@ -2,14 +2,16 @@

from ytmusicapi.setup import setup, setup_oauth
from ytmusicapi.ytmusic import YTMusic
from .mixins.browsing import Lyrics, TimedLyrics, LyricLine
Copy link
Owner

Choose a reason for hiding this comment

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

Please undo the changes to this file. They are not needed and I don't want to start exporting everything from root

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking similar, but then you'll need to create a submodule for these classes to be accessible

Copy link
Owner

Choose a reason for hiding this comment

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

You can already access them: from ytmusicapi.mixins.browsing import TimedLyrics

It's similar for https://github.com/sigma67/ytmusicapi/blob/main/ytmusicapi/parsers/podcasts.py

Although with #621 in mind, it might be wise to move them to a ytmusicapi.models module (one for podcasts and one for lyrics, I guess)


from ytmusicapi.exceptions import YTMusicUserError


OrderType = Literal['a_to_z', 'z_to_a', 'recently_added']
Copy link
Owner

Choose a reason for hiding this comment

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

This is a good change in general, but the name is too broad. Since you introduced an ArtistOrderType elsewhere, this should have a more specific name as well. Maybe LibraryOrderType ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

ytmusicapi/mixins/browsing.py Outdated Show resolved Hide resolved
ytmusicapi/mixins/browsing.py Outdated Show resolved Hide resolved
ytmusicapi/mixins/browsing.py Show resolved Hide resolved
ytmusicapi/mixins/browsing.py Outdated Show resolved Hide resolved
ytmusicapi/mixins/browsing.py Outdated Show resolved Hide resolved
@sigma67 sigma67 added the enhancement New feature or request label Oct 16, 2024
heinrich26 and others added 3 commits October 16, 2024 23:33
@heinrich26 heinrich26 requested a review from sigma67 October 16, 2024 21:58
@heinrich26
Copy link
Contributor Author

finally used pre-commit to fix those formatting complaints 🤷‍♂️

@sigma67
Copy link
Owner

sigma67 commented Dec 17, 2024

Hi @heinrich26 , I am moving this over to #693 as merging is somehow blocked here

@sigma67 sigma67 closed this Dec 17, 2024
@sigma67 sigma67 reopened this Dec 17, 2024
@sigma67 sigma67 closed this Dec 17, 2024
sigma67 added a commit that referenced this pull request Dec 17, 2024
* Added Lyrics w. Timestamps

Added `get_lyrics_with_timestamps` to get lyrics with timestamps.
The Method doesn't try to parse the response as normal lyrics, if no lyrics with timestamps are returned. (could be changed to do so tho, the format is the same)

* Update browsing.py

* Combined both get_lyrics methods into one and fixed some typechecking errors

* Fixed a missing hasTimestamps and added the doccomments to the overloads, because vscode didn't show them otherwise

* Removed the old get_lyrics_with_timestamps method

because idk where it came from...

* fixed remaining issues

* Update uploads.py

reverted some changes that I moved to an extra PR

* removed variable `context` from the Mixin, as it's use was replaced by `yt.as_mobile()`

* fix some formatting complaints by ruff and mypy

* please the linter

* fix union syntax

* improve typing in ytmusic.py

* improve typing

* replace docsbuild.yml with RTD

---------

Co-authored-by: Hendrik Horstmann <65970327+heinrich26@users.noreply.github.com>
Co-authored-by: henrich26 <hendrik-horstmann@o2mail.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants