summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorwn_ <[email protected]>2017-09-17 01:18:05 -0500
committerwn_ <[email protected]>2017-09-17 01:18:05 -0500
commit81d83a68cdb383992a2759dcfdcb08a4d79994ff (patch)
tree0caead1296307eb505423806bcd03708ac491cce /plugins
parent06a19166bda1505eaab655299a36cca3d12cc8cd (diff)
af_redditimgur: Use v.redd.it fallback URL when possible.
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_redditimgur/init.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index c872b429a..9d10c09be 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -159,7 +159,31 @@ class Af_RedditImgur extends Plugin {
$poster_url = false;
}
- $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
+ // IMPORTANT: This assumes the article GUID is kept in "owner_uid,entry_guid" format, and
+ // Reddit feed entries will keep the <id> element (so get_id returns it).
+ $feeditem_id = explode(",", $article["guid"])[1];
+ $source_stream = false;
+ $j = json_decode(fetch_file_contents($article["link"].".json"), true);
+
+ if ($j) {
+ foreach ($j as $listing) {
+ foreach ($listing["data"]["children"] as $child) {
+ // Found the child object corresponding to the article (e.g. same name+ID like "t3_70j63a").
+ if ($child["data"]["name"] == $feeditem_id) {
+ try {
+ $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
+ }
+ catch (Exception $e) {
+ }
+ break 2;
+ }
+ }
+ }
+ }
+
+ if (!$source_stream) {
+ $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
+ }
$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
$found = 1;