From c24cf701c1992bd51253757c432bf5a0abeeee50 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 24 May 2024 15:28:47 +0200 Subject: [PATCH] fix: pages were not in the subclasses because the module was never importet --- music_kraken/download/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/music_kraken/download/__init__.py b/music_kraken/download/__init__.py index 3aa27fc..39e8934 100644 --- a/music_kraken/download/__init__.py +++ b/music_kraken/download/__init__.py @@ -78,6 +78,8 @@ class Downloader: if page_type in self._registered_pages: return + print(page_type) + self._registered_pages[page_type].add(page_type( download_options=self.download_options, fetch_options=self.fetch_options, @@ -94,6 +96,7 @@ class Downloader: def scan_for_pages(self, **kwargs): # assuming the wanted pages are the leaf classes of the interface + from .. import pages leaf_classes = [] class_list = [Page] @@ -342,16 +345,18 @@ class Page: cls.LOGGER = logging.getLogger(cls.__name__) return super().__new__(cls) + @classmethod + def is_leaf_page(cls) -> bool: + return len(cls.__subclasses__()) == 0 + def __init__(self, download_options: DownloadOptions = None, fetch_options: FetchOptions = None, **kwargs): - if self.SOURCE_TYPE is not None: - self.SOURCE_TYPE.register_page(self) + self.SOURCE_TYPE.register_page(self) self.download_options: DownloadOptions = download_options or DownloadOptions() self.fetch_options: FetchOptions = fetch_options or FetchOptions() def __del__(self): - if self.SOURCE_TYPE is not None: - self.SOURCE_TYPE.deregister_page() + self.SOURCE_TYPE.deregister_page() def _search_regex(self, pattern, string, default=None, fatal=True, flags=0, group=None): """