summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-04-23 20:30:29 +0300
committerAndrew Dolgov <[email protected]>2021-04-23 20:30:29 +0300
commite8f78181f1d5a78fcfb58f0a43fb162504fa8e60 (patch)
tree7d704b986a817b353b164e6be7ff734874dbdb3a /plugins
parent88a7130d79981f60337e2118ee8f604df5435659 (diff)
af_redditimgur: instead of generating potentially blacklisted iframes (i.e. huge black boxes),
save found youtube videos as post enclosures for af_youtube_... plugins to deal with later, if enabled
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_redditimgur/init.php28
1 files changed, 9 insertions, 19 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 35eb40950..b16b679af 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -7,6 +7,7 @@ class Af_RedditImgur extends Plugin {
private $dump_json_data = false;
private $fallback_preview_urls = [];
private $default_max_score = 100;
+ private $generated_enclosures = [];
function about() {
return array(null,
@@ -247,6 +248,8 @@ class Af_RedditImgur extends Plugin {
$link_flairs = [];
$apply_nsfw_tags = FeedItem_Common::normalize_categories($this->host->get_array($this, "apply_nsfw_tags", []));
+ $this->generated_enclosures = [];
+
// embed anchor element, before reddit <table> post layout
$anchor = $xpath->query('//body/*')->item(0);
@@ -432,24 +435,11 @@ class Af_RedditImgur extends Plugin {
Debug::log("Handling as youtube: $vid_id", Debug::LOG_VERBOSE);
- $iframe = $doc->createElement("iframe");
- $iframe->setAttribute("class", "youtube-player");
- $iframe->setAttribute("type", "text/html");
- $iframe->setAttribute("width", "640");
- $iframe->setAttribute("height", "385");
- $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
- $iframe->setAttribute("allowfullscreen", "1");
- $iframe->setAttribute("frameborder", "0");
-
- //$br = $doc->createElement('br');
- //$entry->parentNode->insertBefore($iframe, $entry);
- //$entry->parentNode->insertBefore($br, $entry);
-
- // reparent generated iframe because it doesn't scale well inside <td>
- if ($anchor)
- $anchor->parentNode->insertBefore($iframe, $anchor);
- else
- $entry->parentNode->insertBefore($iframe, $entry);
+ /* normalize video URL for af_youtube_... plugins */
+ $video_url = "https://www.youtube.com/v/$vid_id";
+
+ /* push generated video URL to enclosures so that youtube embed plugins would deal with it later (if enabled) */
+ $this->generated_enclosures[] = [$video_url, "text/html", null, null, '', ''];
$found = true;
}
@@ -635,7 +625,7 @@ class Af_RedditImgur extends Plugin {
if ($node && $found) {
$article["content"] = $doc->saveHTML($node);
- $article["enclosures"] = [];
+ $article["enclosures"] = $this->generated_enclosures;
} else if ($content_link) {
$article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
}