feat: fetch_from_url
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Hazel 2024-05-13 18:09:11 +02:00
parent 0343c11a62
commit 0e6fe8187a
1 changed files with 10 additions and 1 deletions

View File

@ -109,15 +109,24 @@ class Pages:
if page is None:
return None
# getting the appropriate function for the page and the object type
source_type = page.get_source_type(source)
if not hasattr(page, fetch_map[source_type]):
return None
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.mark_as_fetched(source.hash_url)
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:
_page_types = set(self._source_to_page)
for src in music_object.source_collection.source_pages: