From 0e6fe8187ab508adeda06361a3ee792ca963a77c Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Mon, 13 May 2024 18:09:11 +0200 Subject: [PATCH] feat: fetch_from_url --- music_kraken/download/page_attributes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/music_kraken/download/page_attributes.py b/music_kraken/download/page_attributes.py index f37517e..8b433b1 100644 --- a/music_kraken/download/page_attributes.py +++ b/music_kraken/download/page_attributes.py @@ -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: