From ec5204cd6cc93209b3e91b5b73df22f5feb135d0 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 3 Jun 2025 20:19:13 +0700 Subject: [PATCH] delay import, fix circular problems --- backend/channel/src/index.py | 5 ++++- backend/playlist/src/index.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/channel/src/index.py b/backend/channel/src/index.py index 929aa5c9..65503ef7 100644 --- a/backend/channel/src/index.py +++ b/backend/channel/src/index.py @@ -14,7 +14,6 @@ from common.src.helper import rand_sleep from common.src.index_generic import YouTubeItem from download.src.thumbnails import ThumbManager from download.src.yt_dlp_base import YtWrap -from playlist.src.index import YoutubePlaylist class YoutubeChannel(YouTubeItem): @@ -215,6 +214,8 @@ class YoutubeChannel(YouTubeItem): def delete_playlists(self): """delete all indexed playlist from es""" + from playlist.src.index import YoutubePlaylist + all_playlists = self.get_indexed_playlists() for playlist in all_playlists: YoutubePlaylist(playlist["playlist_id"]).delete_metadata() @@ -277,6 +278,8 @@ class YoutubeChannel(YouTubeItem): @staticmethod def _index_single_playlist(playlist): """add single playlist if needed""" + from playlist.src.index import YoutubePlaylist + playlist = YoutubePlaylist(playlist[0]) playlist.update_playlist(skip_on_empty=True) diff --git a/backend/playlist/src/index.py b/backend/playlist/src/index.py index 584342b3..3533205a 100644 --- a/backend/playlist/src/index.py +++ b/backend/playlist/src/index.py @@ -7,7 +7,6 @@ functionality: import json from datetime import datetime -from channel.src import index as channel from common.src.env_settings import EnvironmentSettings from common.src.es_connect import ElasticWrap, IndexPaginate from common.src.index_generic import YouTubeItem @@ -74,8 +73,10 @@ class YoutubePlaylist(YouTubeItem): def _ensure_channel(self): """make sure channel is indexed""" + from channel.src.index import YoutubeChannel + channel_id = self.json_data["playlist_channel_id"] - channel_handler = channel.YoutubeChannel(channel_id) + channel_handler = YoutubeChannel(channel_id) channel_handler.build_json(upload=True) def get_local_vids(self) -> list[str]: