index playlist channel if doesn't exist and beter user feedback

This commit is contained in:
simon 2021-11-26 17:34:59 +07:00
parent 31515961e1
commit 1f82f0c40d
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -415,6 +415,7 @@ class PlaylistSubscription:
playlist_handler.add_vids_to_playlist() playlist_handler.add_vids_to_playlist()
thumb = playlist_handler.playlist_dict["playlist_thumbnail"] thumb = playlist_handler.playlist_dict["playlist_thumbnail"]
new_thumbs.append((playlist_id, thumb)) new_thumbs.append((playlist_id, thumb))
self.channel_validate(playlist_handler)
else: else:
self.change_subscribe(playlist_id, subscribe_status=True) self.change_subscribe(playlist_id, subscribe_status=True)
@ -425,6 +426,16 @@ class PlaylistSubscription:
return new_thumbs return new_thumbs
@staticmethod
def channel_validate(playlist_handler):
"""make sure channel of playlist is there"""
channel_id = playlist_handler.playlist_dict["playlist_channel_id"]
channel_handler = YoutubeChannel(channel_id)
if channel_handler.source == "scraped":
channel_handler.channel_dict["channel_subscribed"] = False
channel_handler.upload_to_es()
channel_handler.get_channel_art()
def change_subscribe(self, playlist_id, subscribe_status): def change_subscribe(self, playlist_id, subscribe_status):
"""change the subscribe status of a playlist""" """change the subscribe status of a playlist"""
es_url = self.config["application"]["es_url"] es_url = self.config["application"]["es_url"]
@ -533,6 +544,13 @@ class VideoDownloader:
@staticmethod @staticmethod
def add_pending(): def add_pending():
"""add pending videos to download queue""" """add pending videos to download queue"""
mess_dict = {
"status": "downloading",
"level": "info",
"title": "Looking for videos to download",
"message": "",
}
RedisArchivist().set_message("progress:download", mess_dict)
all_pending, _ = PendingList().get_all_pending() all_pending, _ = PendingList().get_all_pending()
to_add = [i["youtube_id"] for i in all_pending] to_add = [i["youtube_id"] for i in all_pending]
if not to_add: if not to_add:
@ -690,9 +708,22 @@ class VideoDownloader:
if not response.ok and not response.status_code == 404: if not response.ok and not response.status_code == 404:
print(response.text) print(response.text)
def add_subscribed_channels(self):
"""add all channels subscribed to refresh"""
all_subscribed = PlaylistSubscription().get_playlists()
if not all_subscribed:
return
channel_ids = [i["playlist_channel_id"] for i in all_subscribed]
for channel_id in channel_ids:
self.channels.add(channel_id)
return
def validate_playlists(self): def validate_playlists(self):
"""update playlists""" """look for playlist needing to update"""
print("sync playlists") print("sync playlists")
self.add_subscribed_channels()
all_indexed = PendingList().get_all_indexed() all_indexed = PendingList().get_all_indexed()
all_youtube_ids = [i["youtube_id"] for i in all_indexed] all_youtube_ids = [i["youtube_id"] for i in all_indexed]
c_counter = 1 c_counter = 1