reddit-image-wall-getter/reddit_imgs/system/downloader/modules/_cacheable.py

18 lines
484 B
Python
Raw Normal View History

2020-06-01 03:20:23 +00:00
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
from typing import Any, Dict, List, Optional
from ... import simpleDownloader
from .. import cache
def get_link_bytes(link: str, *args: List[Any], **kwargs: Dict[str, Any]) -> Optional[bytes]:
bts = None
cached = cache.get_path_for_caching(link)
if cache.has_file_cache(cached):
bts = cache.read_file_from_cache(cached)
else:
bts = simpleDownloader.getUrlBytes(link, *args, **kwargs)
return bts