diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 2cf17ae6..32e62279 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -20,7 +20,7 @@ from home.src.index.playlist import YoutubePlaylist from home.src.index.video import YoutubeVideo, index_new_video from home.src.index.video_constants import VideoTypeEnum from home.src.ta.config import AppConfig -from home.src.ta.helper import ignore_filelist +from home.src.ta.helper import get_channel_overwrites, ignore_filelist from home.src.ta.settings import EnvironmentSettings @@ -317,26 +317,13 @@ class DownloadPostProcess: def run(self): """run all functions""" - self.channel_overwrites = self.get_channel_overwrites() + self.channel_overwrites = get_channel_overwrites() self.auto_delete_all() self.auto_delete_overwrites() to_refresh = self.refresh_playlist() self.match_videos(to_refresh) self.get_comments() - def get_channel_overwrites(self): - """get overwrites""" - data = { - "query": { - "bool": {"must": [{"exists": {"field": "channel_overwrites"}}]} - }, - "_source": ["channel_id", "channel_overwrites"], - } - result = IndexPaginate("ta_channel", data).get_results() - overwrites = {i["channel_id"]: i["channel_overwrites"] for i in result} - - return overwrites - def auto_delete_all(self): """handle auto delete""" autodelete_days = self.download.config["downloads"]["autodelete_days"] diff --git a/tubearchivist/home/src/ta/helper.py b/tubearchivist/home/src/ta/helper.py index 4cecef4a..7ce056f0 100644 --- a/tubearchivist/home/src/ta/helper.py +++ b/tubearchivist/home/src/ta/helper.py @@ -9,6 +9,7 @@ import random import string import subprocess from datetime import datetime +from typing import Any from urllib.parse import urlparse import requests @@ -241,3 +242,17 @@ def is_missing( dl = [i for i in to_check if i not in existing_ids] return dl + + +def get_channel_overwrites() -> dict[str, dict[str, Any]]: + """get overwrites indexed my channel_id""" + data = { + "query": { + "bool": {"must": [{"exists": {"field": "channel_overwrites"}}]} + }, + "_source": ["channel_id", "channel_overwrites"], + } + result = IndexPaginate("ta_channel", data).get_results() + overwrites = {i["channel_id"]: i["channel_overwrites"] for i in result} + + return overwrites