implemented funtion in search
This commit is contained in:
parent
11974fd2eb
commit
79b2dc4394
@ -196,7 +196,7 @@ class Page:
|
|||||||
def fetch_object_from_source(cls, source: Source, stop_at_level: int = 2):
|
def fetch_object_from_source(cls, source: Source, stop_at_level: int = 2):
|
||||||
obj_type = cls._get_type_of_url(source.url)
|
obj_type = cls._get_type_of_url(source.url)
|
||||||
if obj_type is None:
|
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)
|
music_object = cls._fetch_object_from_source(source=source, obj_type=obj_type, stop_at_level=stop_at_level)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from typing import Tuple, List, Set, Dict, Type, Union, Optional
|
|||||||
from . import page_attributes
|
from . import page_attributes
|
||||||
from .download import Download
|
from .download import Download
|
||||||
from ..abstract import Page
|
from ..abstract import Page
|
||||||
from ...objects import Options, DatabaseObject
|
from ...objects import Options, DatabaseObject, Source
|
||||||
|
|
||||||
|
|
||||||
class MultiPageOptions:
|
class MultiPageOptions:
|
||||||
@ -180,3 +180,18 @@ class Search(Download):
|
|||||||
self._current_option = self._previous_options
|
self._current_option = self._previous_options
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user