Ускорение загрузки треков из плейлиста
This commit is contained in:
parent
557f65aecc
commit
57e6e3bae4
2 changed files with 7 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "yandex-music-downloader"
|
name = "yandex-music-downloader"
|
||||||
version = "3.4.4b0"
|
version = "3.4.5b0"
|
||||||
description = "Загрузчик музыки с сервиса Яндекс.Музыка"
|
description = "Загрузчик музыки с сервиса Яндекс.Музыка"
|
||||||
requires-python = ">=3.9"
|
requires-python = ">=3.9"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ ALBUM_RE = re.compile(r"album/(\d+)$")
|
||||||
ARTIST_RE = re.compile(r"artist/(\d+)$")
|
ARTIST_RE = re.compile(r"artist/(\d+)$")
|
||||||
PLAYLIST_RE = re.compile(r"([\w\-._]+)/playlists/(\d+)$")
|
PLAYLIST_RE = re.compile(r"([\w\-._]+)/playlists/(\d+)$")
|
||||||
|
|
||||||
|
FETCH_PAGE_SIZE = 10
|
||||||
|
|
||||||
logger = logging.getLogger("yandex-music-downloader")
|
logger = logging.getLogger("yandex-music-downloader")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -270,8 +272,10 @@ def main():
|
||||||
|
|
||||||
def playlist_tracks_gen() -> Generator[Track]:
|
def playlist_tracks_gen() -> Generator[Track]:
|
||||||
tracks = playlist.fetch_tracks()
|
tracks = playlist.fetch_tracks()
|
||||||
for track in tracks:
|
for i in range(0, len(tracks), FETCH_PAGE_SIZE):
|
||||||
yield track.fetch_track()
|
yield from client.tracks(
|
||||||
|
[track.id for track in tracks[i : i + FETCH_PAGE_SIZE]]
|
||||||
|
)
|
||||||
|
|
||||||
result_tracks = playlist_tracks_gen()
|
result_tracks = playlist_tracks_gen()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue