Учет пропущенных треков в общем количестве
This commit is contained in:
parent
d9c40a394d
commit
7c9d503bc6
2 changed files with 15 additions and 8 deletions
|
|
@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "yandex-music-downloader"
|
name = "yandex-music-downloader"
|
||||||
version = "3.5.3"
|
version = "3.5.4"
|
||||||
description = "Загрузчик музыки с сервиса Яндекс.Музыка"
|
description = "Загрузчик музыки с сервиса Яндекс.Музыка"
|
||||||
requires-python = ">=3.9"
|
requires-python = ">=3.9"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
||||||
21
ymd/cli.py
21
ymd/cli.py
|
|
@ -260,23 +260,30 @@ def main():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def albums_gen() -> Generator[Album]:
|
def albums_id_gen() -> Generator[int]:
|
||||||
has_next = True
|
has_next = True
|
||||||
page = 0
|
page = 0
|
||||||
while has_next:
|
while has_next:
|
||||||
if albums := client.artists_direct_albums(args.artist_id, page):
|
if albums_info := client.artists_direct_albums(args.artist_id, page):
|
||||||
yield from albums.albums
|
for album in albums_info.albums:
|
||||||
|
if filter_album(album):
|
||||||
|
assert album.id
|
||||||
|
yield album.id
|
||||||
|
else:
|
||||||
|
nonlocal total_track_count
|
||||||
|
if (
|
||||||
|
track_count := album.track_count
|
||||||
|
) and total_track_count is not None:
|
||||||
|
total_track_count -= track_count
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if pager := albums.pager:
|
if pager := albums_info.pager:
|
||||||
page = pager.page + 1
|
page = pager.page + 1
|
||||||
has_next = pager.per_page * page < pager.total
|
has_next = pager.per_page * page < pager.total
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
result_tracks = album_tracks_gen(
|
result_tracks = album_tracks_gen(albums_id_gen())
|
||||||
a.id for a in albums_gen() if filter_album(a) and a.id is not None
|
|
||||||
)
|
|
||||||
artist = client.artists(args.artist_id)[0]
|
artist = client.artists(args.artist_id)[0]
|
||||||
if counts := artist.counts:
|
if counts := artist.counts:
|
||||||
total_track_count = counts.tracks
|
total_track_count = counts.tracks
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue