mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
validate existence of playlist entry in index
This commit is contained in:
parent
e3f0075132
commit
8932a6bc02
@ -440,9 +440,10 @@ class YoutubePlaylist:
|
||||
ES_URL = CONFIG["application"]["es_url"]
|
||||
ES_AUTH = CONFIG["application"]["es_auth"]
|
||||
|
||||
def __init__(self, playlist_id):
|
||||
def __init__(self, playlist_id, all_youtube_ids=False):
|
||||
self.playlist_id = playlist_id
|
||||
self.stamp = int(datetime.now().strftime("%s"))
|
||||
self.all_youtube_ids = all_youtube_ids
|
||||
self.playlist_dict = False
|
||||
|
||||
def get_playlist_dict(self, scrape=False):
|
||||
@ -514,13 +515,16 @@ class YoutubePlaylist:
|
||||
all_members = []
|
||||
for idx, entry in enumerate(playlist["entries"]):
|
||||
uploader = entry["uploader"]
|
||||
youtube_id = entry["id"]
|
||||
downloaded = youtube_id in self.all_youtube_ids
|
||||
if not uploader:
|
||||
continue
|
||||
to_append = {
|
||||
"youtube_id": entry["id"],
|
||||
"youtube_id": youtube_id,
|
||||
"title": entry["title"],
|
||||
"uploader": uploader,
|
||||
"idx": idx,
|
||||
"downloaded": downloaded,
|
||||
}
|
||||
all_members.append(to_append)
|
||||
|
||||
|
@ -208,9 +208,14 @@ def index_channel_playlists(channel_id):
|
||||
channel_handler = YoutubeChannel(channel_id)
|
||||
all_playlists = channel_handler.get_all_playlists()
|
||||
|
||||
all_indexed = PendingList().get_all_indexed()
|
||||
all_youtube_ids = [i["_source"]["youtube_id"] for i in all_indexed]
|
||||
|
||||
for playlist_id, playlist_title in all_playlists:
|
||||
print("add playlist: " + playlist_title)
|
||||
playlist_handler = YoutubePlaylist(playlist_id)
|
||||
playlist_handler = YoutubePlaylist(
|
||||
playlist_id, all_youtube_ids=all_youtube_ids
|
||||
)
|
||||
playlist_handler.get_playlist_dict()
|
||||
playlist_handler.upload_to_es()
|
||||
playlist_handler.add_vids_to_playlist()
|
||||
|
Loading…
Reference in New Issue
Block a user