af_redditimgur: check content-type before downloading data for og:image and imgur pages

This commit is contained in:
Andrew Dolgov 2021-11-24 08:27:10 +03:00
parent 204f92b926
commit 831648e3c8
1 changed files with 60 additions and 45 deletions

View File

@ -496,6 +496,10 @@ class Af_RedditImgur extends Plugin {
Debug::log("handling as imgur page/whatever", Debug::LOG_VERBOSE);
$content_type = $this->get_content_type($entry_href);
if ($content_type && strpos($content_type, "text/html") !== false) {
$content = UrlHelper::fetch(["url" => $entry_href,
"http_accept" => "text/*"]);
@ -521,6 +525,10 @@ class Af_RedditImgur extends Plugin {
}
}
}
} else {
Debug::log("skipping imgur $entry_href because of content type: $content_type", Debug::LOG_VERBOSE);
}
}
// wtf is this even
@ -543,6 +551,10 @@ class Af_RedditImgur extends Plugin {
if (!$found) {
Debug::log("looking for meta og:image", Debug::LOG_VERBOSE);
$content_type = $this->get_content_type($entry_href);
if ($content_type && strpos($content_type, "text/html") !== false) {
$content = UrlHelper::fetch(["url" => $entry_href,
"http_accept" => "text/*"]);
@ -591,6 +603,9 @@ class Af_RedditImgur extends Plugin {
}
}
}
} else {
Debug::log("BODY: skipping $entry_href because of content type: $content_type", Debug::LOG_VERBOSE);
}
}
}