1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 05:25:56 +00:00

* DiskCache: add download() helper

* Af_Comics_Gocomics_FarSide: cache linked images because it seems to
be required anyway
This commit is contained in:
Andrew Dolgov
2021-11-15 23:22:21 +03:00
parent 8cd69fe15c
commit b2952843f5
2 changed files with 35 additions and 1 deletions

View File

@@ -50,8 +50,22 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter {
if ($content_node) {
$imgs = $xpath->query('//img[@data-src]', $content_node);
$cache = new DiskCache("images");
foreach ($imgs as $img) {
$img->setAttribute('src', $img->getAttribute('data-src'));
$image_url = $img->getAttribute('data-src');
$local_filename = sha1($image_url);
if ($image_url) {
$img->setAttribute('src', $image_url);
// try to cache image locally because they just 401 us otherwise
if (!$cache->exists($local_filename)) {
Debug::log("[Af_Comics_Gocomics_FarSide] caching: $image_url", Debug::LOG_VERBOSE);
$res = $cache->download($image_url, sha1($image_url), ["http_referrer" => $image_url]);
Debug::log("[Af_Comics_Gocomics_FarSide] cache result: $res", Debug::LOG_VERBOSE);
}
}
}
$junk_elems = $xpath->query("//*[@data-shareable-popover]");