diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py index 5a71522..cfa1875 100644 --- a/tubearchivist/api/views.py +++ b/tubearchivist/api/views.py @@ -123,7 +123,7 @@ class VideoProgressView(ApiBaseView): """set progress position in redis""" position = request.data.get("position", 0) key = f"{request.user.id}:progress:{video_id}" - message = {"position": position} + message = {"position": position, "youtube_id": video_id} RedisArchivist().set_message(key, message, expire=False) self.response = request.data diff --git a/tubearchivist/home/src/download/subscriptions.py b/tubearchivist/home/src/download/subscriptions.py index 2e4a29f..84627b6 100644 --- a/tubearchivist/home/src/download/subscriptions.py +++ b/tubearchivist/home/src/download/subscriptions.py @@ -48,7 +48,13 @@ class ChannelSubscription: } if limit: obs["playlistend"] = self.channel_size - chan = yt_dlp.YoutubeDL(obs).extract_info(url, download=False) + + try: + chan = yt_dlp.YoutubeDL(obs).extract_info(url, download=False) + except yt_dlp.utils.DownloadError: + print(f"{channel_id}: failed to extract videos, skipping.") + return False + last_videos = [(i["id"], i["title"]) for i in chan["entries"]] return last_videos @@ -66,9 +72,11 @@ class ChannelSubscription: for idx, channel in enumerate(all_channels): channel_id = channel["channel_id"] last_videos = self.get_last_youtube_videos(channel_id) - for video in last_videos: - if video[0] not in to_ignore: - missing_videos.append(video[0]) + + if last_videos: + for video in last_videos: + if video[0] not in to_ignore: + missing_videos.append(video[0]) # notify message = { "status": "message:rescan", diff --git a/tubearchivist/home/src/ta/ta_redis.py b/tubearchivist/home/src/ta/ta_redis.py index d131c96..6a9efea 100644 --- a/tubearchivist/home/src/ta/ta_redis.py +++ b/tubearchivist/home/src/ta/ta_redis.py @@ -59,6 +59,19 @@ class RedisArchivist: return json_str + def list_items(self, query): + """list all matches""" + reply = self.redis_connection.execute_command( + "KEYS", self.NAME_SPACE + query + "*" + ) + all_matches = [i.decode().lstrip(self.NAME_SPACE) for i in reply] + all_results = [] + for match in all_matches: + json_str = self.get_message(match) + all_results.append(json_str) + + return all_results + def del_message(self, key): """delete key from redis""" response = self.redis_connection.execute_command( diff --git a/tubearchivist/home/templates/home/base.html b/tubearchivist/home/templates/home/base.html index 9824e3f..5516282 100644 --- a/tubearchivist/home/templates/home/base.html +++ b/tubearchivist/home/templates/home/base.html @@ -132,7 +132,7 @@