From 3722f11a65b2f26af36be461983981a7342dae34 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 7 May 2022 09:34:51 +0700 Subject: [PATCH] cleanup cookie file after task --- tubearchivist/home/src/download/queue.py | 12 ++++++++++++ tubearchivist/home/src/download/yt_dlp_handler.py | 7 +------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tubearchivist/home/src/download/queue.py b/tubearchivist/home/src/download/queue.py index 8b4322e..27217c4 100644 --- a/tubearchivist/home/src/download/queue.py +++ b/tubearchivist/home/src/download/queue.py @@ -145,6 +145,16 @@ class PendingList(PendingIndex): cookie_path = CookieHandler().use() self.yt_obs.update({"cookiefile": cookie_path}) + def close_config(self): + """remove config after task finished""" + config = AppConfig().config + if config["downloads"]["cookie_import"]: + CookieHandler().hide() + try: + del self.yt_obs["cookiefile"] + except KeyError: + pass + def parse_url_list(self): """extract youtube ids from list""" self.missing_videos = [] @@ -225,6 +235,8 @@ class PendingList(PendingIndex): query_str = "\n".join(bulk_list) _, _ = ElasticWrap("_bulk").post(query_str, ndjson=True) + self.close_config() + def _notify_add(self, idx): """send notification for adding videos to download queue""" progress = f"{idx + 1}/{len(self.missing_videos)}" diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index fd91432..2c24cb0 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -41,7 +41,7 @@ class DownloadPostProcess: self.auto_delete_all() self.auto_delete_overwrites() self.validate_playlists() - self.clear_cookie() + self.pending.close_config() def auto_delete_all(self): """handle auto delete""" @@ -141,11 +141,6 @@ class DownloadPostProcess: else: RedisArchivist().set_message("message:download", mess_dict) - def clear_cookie(self): - """hide cookie file""" - if self.download.config["downloads"]["cookie_import"]: - CookieHandler().hide() - class VideoDownloader: """