feat: fetch_from_url
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
0343c11a62
commit
0e6fe8187a
@ -109,15 +109,24 @@ class Pages:
|
|||||||
if page is None:
|
if page is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# getting the appropriate function for the page and the object type
|
||||||
source_type = page.get_source_type(source)
|
source_type = page.get_source_type(source)
|
||||||
if not hasattr(page, fetch_map[source_type]):
|
if not hasattr(page, fetch_map[source_type]):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
func = getattr(page, fetch_map[source_type])(source=source, **kwargs)
|
func = getattr(page, fetch_map[source_type])(source=source, **kwargs)
|
||||||
|
|
||||||
|
# fetching the data object and marking it as fetched
|
||||||
data_object: DataObject = func(source=source)
|
data_object: DataObject = func(source=source)
|
||||||
data_object.mark_as_fetched(source.hash_url)
|
data_object.mark_as_fetched(source.hash_url)
|
||||||
return data_object
|
return data_object
|
||||||
|
|
||||||
|
def fetch_from_url(self, url: str) -> Optional[DataObject]:
|
||||||
|
source = Source.match_url(url, SourcePages.MANUAL)
|
||||||
|
if source is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self.fetch_from_source(source=source)
|
||||||
|
|
||||||
def is_downloadable(self, music_object: DataObject) -> bool:
|
def is_downloadable(self, music_object: DataObject) -> bool:
|
||||||
_page_types = set(self._source_to_page)
|
_page_types = set(self._source_to_page)
|
||||||
for src in music_object.source_collection.source_pages:
|
for src in music_object.source_collection.source_pages:
|
||||||
|
Loading…
Reference in New Issue
Block a user