feat: implemented consistent settings
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
40e9366a0b
commit
aafbba3b1c
@ -48,7 +48,7 @@ class Pages:
|
|||||||
self.download_options: DownloadOptions = download_options or DownloadOptions()
|
self.download_options: DownloadOptions = download_options or DownloadOptions()
|
||||||
self.fetch_options: FetchOptions = fetch_options or FetchOptions()
|
self.fetch_options: FetchOptions = fetch_options or FetchOptions()
|
||||||
|
|
||||||
scan_for_pages()
|
scan_for_pages(download_options=self.download_options, fetch_options=self.fetch_options, **kwargs)
|
||||||
|
|
||||||
def search(self, query: Query) -> SearchResults:
|
def search(self, query: Query) -> SearchResults:
|
||||||
result = SearchResults()
|
result = SearchResults()
|
||||||
|
@ -36,7 +36,7 @@ def deregister_page(page_type: Type[Page]):
|
|||||||
p.__del__()
|
p.__del__()
|
||||||
del _registered_pages[page_type]
|
del _registered_pages[page_type]
|
||||||
|
|
||||||
def scan_for_pages():
|
def scan_for_pages(**kwargs):
|
||||||
# assuming the wanted pages are the leaf classes of the interface
|
# assuming the wanted pages are the leaf classes of the interface
|
||||||
leaf_classes = []
|
leaf_classes = []
|
||||||
|
|
||||||
@ -51,6 +51,5 @@ def scan_for_pages():
|
|||||||
else:
|
else:
|
||||||
_class_list.extend(_class_subclasses)
|
_class_list.extend(_class_subclasses)
|
||||||
|
|
||||||
print(leaf_classes)
|
|
||||||
for leaf_class in leaf_classes:
|
for leaf_class in leaf_classes:
|
||||||
register_page(leaf_class)
|
register_page(leaf_class, **kwargs)
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union, Type, Dict, Set, List, Tuple, TypedDict
|
from typing import Optional, Union, Type, Dict, Set, List, Tuple, TypedDict, TYPE_CHECKING
|
||||||
from string import Formatter
|
from string import Formatter
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..download.page_attributes import DownloadOptions, FetchOptions
|
||||||
from ..connection import Connection
|
from ..connection import Connection
|
||||||
from ..objects import (
|
from ..objects import (
|
||||||
Song,
|
Song,
|
||||||
@ -34,18 +38,6 @@ from ..utils import trace, output, BColors
|
|||||||
INDEPENDENT_DB_OBJECTS = Union[Label, Album, Artist, Song]
|
INDEPENDENT_DB_OBJECTS = Union[Label, Album, Artist, Song]
|
||||||
INDEPENDENT_DB_TYPES = Union[Type[Song], Type[Album], Type[Artist], Type[Label]]
|
INDEPENDENT_DB_TYPES = Union[Type[Song], Type[Album], Type[Artist], Type[Label]]
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class FetchOptions:
|
|
||||||
download_all: bool = False
|
|
||||||
album_type_blacklist: Set[AlbumType] = field(default_factory=lambda: set(AlbumType(a) for a in main_settings["album_type_blacklist"]))
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class DownloadOptions:
|
|
||||||
download_all: bool = False
|
|
||||||
album_type_blacklist: Set[AlbumType] = field(default_factory=lambda: set(AlbumType(a) for a in main_settings["album_type_blacklist"]))
|
|
||||||
|
|
||||||
process_audio_if_found: bool = False
|
|
||||||
process_metadata_if_found: bool = True
|
|
||||||
|
|
||||||
class Page:
|
class Page:
|
||||||
REGISTER = True
|
REGISTER = True
|
||||||
@ -56,14 +48,14 @@ class Page:
|
|||||||
cls.LOGGER = logging.getLogger(cls.__name__)
|
cls.LOGGER = logging.getLogger(cls.__name__)
|
||||||
return super().__new__(cls)
|
return super().__new__(cls)
|
||||||
|
|
||||||
def __init__(self, download_options: DownloadOptions = None, fetch_options: FetchOptions = None):
|
def __init__(self, download_options: DownloadOptions = None, fetch_options: FetchOptions = None, **kwargs):
|
||||||
self.SOURCE_TYPE.register_page(self)
|
self.SOURCE_TYPE.register_page(self)
|
||||||
|
|
||||||
self.download_options: DownloadOptions = download_options or DownloadOptions()
|
self.download_options: DownloadOptions = download_options or DownloadOptions()
|
||||||
self.fetch_options: FetchOptions = fetch_options or FetchOptions()
|
self.fetch_options: FetchOptions = fetch_options or FetchOptions()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.SOURCE_TYPE.deregister_page(self)
|
self.SOURCE_TYPE.deregister_page()
|
||||||
|
|
||||||
def _search_regex(self, pattern, string, default=None, fatal=True, flags=0, group=None):
|
def _search_regex(self, pattern, string, default=None, fatal=True, flags=0, group=None):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user