implemented funtion in search

This commit is contained in:
Hellow2 2023-03-30 12:23:57 +02:00
parent 11974fd2eb
commit 79b2dc4394
2 changed files with 17 additions and 2 deletions

View File

@ -196,7 +196,7 @@ class Page:
def fetch_object_from_source(cls, source: Source, stop_at_level: int = 2):
obj_type = cls._get_type_of_url(source.url)
if obj_type is None:
return Artist()
return None
music_object = cls._fetch_object_from_source(source=source, obj_type=obj_type, stop_at_level=stop_at_level)

View File

@ -4,7 +4,7 @@ from typing import Tuple, List, Set, Dict, Type, Union, Optional
from . import page_attributes
from .download import Download
from ..abstract import Page
from ...objects import Options, DatabaseObject
from ...objects import Options, DatabaseObject, Source
class MultiPageOptions:
@ -180,3 +180,18 @@ class Search(Download):
self._current_option = self._previous_options
except IndexError:
pass
def search_url(self, url: str) -> bool:
source = Source.match_url(url=url)
if source is None:
return False
new_object = self.fetch_source(source)
if new_object is None:
return False
page = page_attributes.SOURCE_PAGE_MAP[source.page_enum]
mpo = self.next_options
mpo[page] = new_object.options
return True