diff --git a/tubearchivist/home/src/download/queue.py b/tubearchivist/home/src/download/queue.py index ee7ba46..cd20c9b 100644 --- a/tubearchivist/home/src/download/queue.py +++ b/tubearchivist/home/src/download/queue.py @@ -123,6 +123,26 @@ class PendingInteract: response, status_code = ElasticWrap(path).get() return response["_source"], status_code + def get_channel(self): + """ + get channel metadata from queue to not depend on channel to be indexed + """ + data = { + "size": 1, + "query": {"term": {"channel_id": {"value": self.youtube_id}}}, + } + response, _ = ElasticWrap("ta_download/_search").get(data=data) + hits = response["hits"]["hits"] + if not hits: + channel_name = "NA" + else: + channel_name = hits[0]["_source"].get("channel_name", "NA") + + return { + "channel_id": self.youtube_id, + "channel_name": channel_name, + } + class PendingList(PendingIndex): """manage the pending videos list""" diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 4918aca..3e44373 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -15,6 +15,7 @@ from django.contrib.auth.forms import AuthenticationForm from django.http import JsonResponse from django.shortcuts import redirect, render from django.views import View +from home.src.download.queue import PendingInteract from home.src.download.yt_dlp_base import CookieHandler from home.src.es.backup import ElasticBackup from home.src.es.connect import ElasticWrap @@ -32,7 +33,7 @@ from home.src.frontend.forms import ( UserSettingsForm, ) from home.src.frontend.searching import SearchHandler -from home.src.index.channel import YoutubeChannel, channel_overwrites +from home.src.index.channel import channel_overwrites from home.src.index.generic import Pagination from home.src.index.playlist import YoutubePlaylist from home.src.index.reindex import ReindexProgress @@ -401,12 +402,11 @@ class DownloadView(ArchivistResultsView): {"term": {"channel_id": {"value": channel_filter}}} ) - channel = YoutubeChannel(channel_filter) - channel.get_from_es() + channel = PendingInteract(channel_filter).get_channel() self.context.update( { - "channel_filter_id": channel_filter, - "channel_filter_name": channel.json_data["channel_name"], + "channel_filter_id": channel.get("channel_id"), + "channel_filter_name": channel.get("channel_name"), } )