mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 22:59:39 +00:00
fix playlist incomplete index, slice in queue, #942
This commit is contained in:
@@ -266,12 +266,14 @@ class PendingList(PendingIndex):
|
|||||||
def _parse_playlist(self, url: str, limit: int | None):
|
def _parse_playlist(self, url: str, limit: int | None):
|
||||||
"""fast parse playlist"""
|
"""fast parse playlist"""
|
||||||
playlist = YoutubePlaylist(url)
|
playlist = YoutubePlaylist(url)
|
||||||
playlist.update_playlist(limit=limit)
|
playlist.update_playlist()
|
||||||
if not playlist.youtube_meta:
|
if not playlist.youtube_meta:
|
||||||
print(f"{url}: playlist metadata extraction failed, skipping")
|
print(f"{url}: playlist metadata extraction failed, skipping")
|
||||||
return
|
return
|
||||||
|
|
||||||
video_results = playlist.youtube_meta["entries"]
|
video_results = playlist.youtube_meta["entries"]
|
||||||
|
if limit:
|
||||||
|
video_results = video_results[:limit]
|
||||||
|
|
||||||
total = len(video_results)
|
total = len(video_results)
|
||||||
for idx, video_data in enumerate(video_results, start=1):
|
for idx, video_data in enumerate(video_results, start=1):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class YoutubePlaylist(YouTubeItem):
|
|||||||
self.all_members = False
|
self.all_members = False
|
||||||
self.nav = False
|
self.nav = False
|
||||||
|
|
||||||
def build_json(self, scrape=False, limit: int | None = None):
|
def build_json(self, scrape=False):
|
||||||
"""collection to create json_data"""
|
"""collection to create json_data"""
|
||||||
self.get_from_es()
|
self.get_from_es()
|
||||||
if self.json_data:
|
if self.json_data:
|
||||||
@@ -40,9 +40,8 @@ class YoutubePlaylist(YouTubeItem):
|
|||||||
subscribed = False
|
subscribed = False
|
||||||
playlist_sort_order = "top"
|
playlist_sort_order = "top"
|
||||||
|
|
||||||
limit_str = limit if limit is not None else ""
|
|
||||||
sort_order = 1 if playlist_sort_order == "top" else -1
|
sort_order = 1 if playlist_sort_order == "top" else -1
|
||||||
playlist_items = f":{limit_str}:{sort_order}"
|
playlist_items = f"::{sort_order}"
|
||||||
|
|
||||||
if scrape or not self.json_data:
|
if scrape or not self.json_data:
|
||||||
self.get_from_youtube(
|
self.get_from_youtube(
|
||||||
@@ -198,9 +197,9 @@ class YoutubePlaylist(YouTubeItem):
|
|||||||
if status_code == 200:
|
if status_code == 200:
|
||||||
print(f"{self.youtube_id}: removed {video_id} from playlist")
|
print(f"{self.youtube_id}: removed {video_id} from playlist")
|
||||||
|
|
||||||
def update_playlist(self, skip_on_empty=False, limit: int | None = None):
|
def update_playlist(self, skip_on_empty=False):
|
||||||
"""update metadata for playlist with data from YouTube"""
|
"""update metadata for playlist with data from YouTube"""
|
||||||
self.build_json(scrape=True, limit=limit)
|
self.build_json(scrape=True)
|
||||||
if not self.json_data:
|
if not self.json_data:
|
||||||
# return false to deactivate
|
# return false to deactivate
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user