summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSelf-Perfection <[email protected]>2018-07-14 16:29:39 +0300
committerSelf-Perfection <[email protected]>2018-07-14 19:16:40 +0300
commit1cb3084d53025cfcc6873aa4f79afdd79d10252f (patch)
tree32e550d349d8ef17be3c9a4fa9cbfd346c5bf4d8 /plugins
parent6e6c3a878d561099ea5c50181a1eb4d4b4494552 (diff)
Replace tumblr videos with HD versions
Alternative approach might be extracting replacement URL from "hdUrl" field of custom property "data-crt-options", but stripping last segment of video URL is way easier and seems equally robust.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_tumblr_1280/init.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/plugins/af_tumblr_1280/init.php b/plugins/af_tumblr_1280/init.php
index d74253b57..8aba0e652 100755
--- a/plugins/af_tumblr_1280/init.php
+++ b/plugins/af_tumblr_1280/init.php
@@ -4,7 +4,7 @@ class Af_Tumblr_1280 extends Plugin {
function about() {
return array(1.0,
- "Replace Tumblr pictures with largest size if available (requires CURL)",
+ "Replace Tumblr pictures and videos with largest size if available (requires CURL)",
"fox");
}
@@ -64,6 +64,19 @@ class Af_Tumblr_1280 extends Plugin {
}
}
+ $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]');
+
+ foreach ($video_sources as $source) {
+ $src = $source->getAttribute("src");
+
+ $new_src = preg_replace("/\/\d{3}$/", "", $src);
+
+ if ($src != $new_src) {
+ $source->setAttribute("src", $new_src);
+ $found = true;
+ }
+ }
+
if ($found) {
$doc->removeChild($doc->firstChild); //remove doctype
$article["content"] = $doc->saveHTML();