* 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>
This commit is contained in:
parent
bb4bf4d3e1
commit
b86654fbaf
12 changed files with 246 additions and 82 deletions
|
|
@ -6,6 +6,7 @@ from unittest import mock
|
|||
import pytest
|
||||
|
||||
from tests.test_helpers import is_ci
|
||||
from ytmusicapi.models.lyrics import LyricLine
|
||||
|
||||
|
||||
class TestBrowsing:
|
||||
|
|
@ -173,9 +174,24 @@ class TestBrowsing:
|
|||
|
||||
def test_get_lyrics(self, config, yt, sample_video):
|
||||
playlist = yt.get_watch_playlist(sample_video)
|
||||
# test normal lyrics
|
||||
lyrics_song = yt.get_lyrics(playlist["lyrics"])
|
||||
assert lyrics_song["lyrics"] is not None
|
||||
assert lyrics_song["source"] is not None
|
||||
assert lyrics_song is not None
|
||||
assert isinstance(lyrics_song["lyrics"], str)
|
||||
assert lyrics_song["hasTimestamps"] is False
|
||||
|
||||
# test lyrics with timestamps
|
||||
lyrics_song = yt.get_lyrics(playlist["lyrics"], timestamps=True)
|
||||
assert lyrics_song is not None
|
||||
assert len(lyrics_song["lyrics"]) >= 1
|
||||
assert lyrics_song["hasTimestamps"] is True
|
||||
|
||||
# check the LyricLine object
|
||||
song = lyrics_song["lyrics"][0]
|
||||
assert isinstance(song, LyricLine)
|
||||
assert isinstance(song.text, str)
|
||||
assert song.start_time <= song.end_time
|
||||
assert isinstance(song.id, int)
|
||||
|
||||
playlist = yt.get_watch_playlist(config["uploads"]["private_upload_id"])
|
||||
assert playlist["lyrics"] is None
|
||||
|
|
|
|||
Loading…
Reference in a new issue