fix playlist incomplete index, slice in queue, #942
This commit is contained in:
parent
be278fe5f6
commit
c6d0e02f16
|
|
@ -266,12 +266,14 @@ class PendingList(PendingIndex):
|
|||
def _parse_playlist(self, url: str, limit: int | None):
|
||||
"""fast parse playlist"""
|
||||
playlist = YoutubePlaylist(url)
|
||||
playlist.update_playlist(limit=limit)
|
||||
playlist.update_playlist()
|
||||
if not playlist.youtube_meta:
|
||||
print(f"{url}: playlist metadata extraction failed, skipping")
|
||||
return
|
||||
|
||||
video_results = playlist.youtube_meta["entries"]
|
||||
if limit:
|
||||
video_results = video_results[:limit]
|
||||
|
||||
total = len(video_results)
|
||||
for idx, video_data in enumerate(video_results, start=1):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class YoutubePlaylist(YouTubeItem):
|
|||
self.all_members = 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"""
|
||||
self.get_from_es()
|
||||
if self.json_data:
|
||||
|
|
@ -40,9 +40,8 @@ class YoutubePlaylist(YouTubeItem):
|
|||
subscribed = False
|
||||
playlist_sort_order = "top"
|
||||
|
||||
limit_str = limit if limit is not None else ""
|
||||
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:
|
||||
self.get_from_youtube(
|
||||
|
|
@ -198,9 +197,9 @@ class YoutubePlaylist(YouTubeItem):
|
|||
if status_code == 200:
|
||||
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"""
|
||||
self.build_json(scrape=True, limit=limit)
|
||||
self.build_json(scrape=True)
|
||||
if not self.json_data:
|
||||
# return false to deactivate
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in New Issue