summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorlllusion3418 <[email protected]>2020-03-12 11:08:33 +0100
committerlllusion3418 <[email protected]>2020-03-12 11:08:33 +0100
commitcdde23b4dc948bdc2af659802ec1f53e351d7dae (patch)
tree253ce9036b434167d7e5ead89b020ee7db375aac /classes
parentb4287a2e986f409044baf2ce9965f20cff3a7986 (diff)
actually download <video> posters to media cache
video[@poster] is already supported in the rewriting logic but never actually downloaded
Diffstat (limited to 'classes')
-rwxr-xr-xclasses/rssutils.php38
1 files changed, 20 insertions, 18 deletions
diff --git a/classes/rssutils.php b/classes/rssutils.php
index 87e194603..be79dc27b 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -1229,33 +1229,35 @@ class RSSUtils {
if ($doc->loadHTML($html)) {
$xpath = new DOMXPath($doc);
- $entries = $xpath->query('(//img[@src])|(//video/source[@src])|(//audio/source[@src])');
+ $entries = $xpath->query('(//img[@src])|(//video/source[@src])|(//audio/source[@src])|(//video[@poster])');
foreach ($entries as $entry) {
- if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
- $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
+ foreach (array('src', 'poster') as $attr) {
+ if ($entry->hasAttribute($attr) && strpos($entry->getAttribute($attr), "data:") !== 0) {
+ $src = rewrite_relative_url($site_url, $entry->getAttribute($attr));
- $local_filename = sha1($src);
+ $local_filename = sha1($src);
- Debug::log("cache_media: checking $src", Debug::$LOG_VERBOSE);
+ Debug::log("cache_media: checking $src", Debug::$LOG_VERBOSE);
- if (!$cache->exists($local_filename)) {
- Debug::log("cache_media: downloading: $src to $local_filename", Debug::$LOG_VERBOSE);
+ if (!$cache->exists($local_filename)) {
+ Debug::log("cache_media: downloading: $src to $local_filename", Debug::$LOG_VERBOSE);
- global $fetch_last_error_code;
- global $fetch_last_error;
+ global $fetch_last_error_code;
+ global $fetch_last_error;
- $file_content = fetch_file_contents(array("url" => $src,
- "http_referrer" => $src,
- "max_size" => MAX_CACHE_FILE_SIZE));
+ $file_content = fetch_file_contents(array("url" => $src,
+ "http_referrer" => $src,
+ "max_size" => MAX_CACHE_FILE_SIZE));
- if ($file_content) {
- $cache->put($local_filename, $file_content);
- } else {
- Debug::log("cache_media: failed with $fetch_last_error_code: $fetch_last_error");
+ if ($file_content) {
+ $cache->put($local_filename, $file_content);
+ } else {
+ Debug::log("cache_media: failed with $fetch_last_error_code: $fetch_last_error");
+ }
+ } else if ($cache->isWritable($local_filename)) {
+ $cache->touch($local_filename);
}
- } else if ($cache->isWritable($local_filename)) {
- $cache->touch($local_filename);
}
}
}