_check_cache_expired modified to be able to access full object

for more advanced calculations about caching
master
Felix Stupp 2 years ago
parent 2e97563e0e
commit 54748a9540
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -38,8 +38,8 @@ class TtRssCollectionExtractor(CollectionExtractor[HeadlineList]):
def can_extract_offline(self, uri: str) -> bool:
return True
def _cache_expired(self, date: datetime) -> bool:
return (datetime.now() - date) > timedelta(minutes=10)
def _cache_expired(self, object: MediaCollection) -> bool:
return (datetime.now() - object.last_updated) > timedelta(minutes=10)
def _extract_offline(self, uri: str) -> ExtractedData[HeadlineList]:
return ExtractedData(

@ -53,8 +53,8 @@ class YouTubeCollectionExtractor(CollectionExtractor[Dict]):
def can_extract_offline(self, uri: str) -> bool:
return True
def _cache_expired(self, date: datetime) -> bool:
return (datetime.now() - date) > timedelta(hours=4)
def _cache_expired(self, object: MediaCollection) -> bool:
return (datetime.now() - object.last_updated) > timedelta(hours=4)
def _extract_offline(self, uri: str) -> ExtractedData[Dict]:
playlist_id = self.__convert_if_required(self.__get_id(uri))

@ -123,7 +123,7 @@ class GeneralExtractor(Generic[E, T]):
def can_extract_offline(self, uri: str) -> bool:
return False
def _cache_expired(self, date: datetime) -> bool:
def _cache_expired(self, object: E) -> bool:
return False
def _extract_offline_only(self, uri: str) -> ExtractedData[T]:
@ -163,7 +163,7 @@ class GeneralExtractor(Generic[E, T]):
if (
object.was_extracted
and check_cache_expired
and not self._cache_expired(object.last_updated)
and not self._cache_expired(object)
):
logging.debug(
f"Skip info for element as already extracted and cache valid: {object.title!r}"

Loading…
Cancel
Save