reddit: import comment counts

This commit is contained in:
Andrew Dolgov 2021-03-02 21:32:20 +03:00
parent 6f93c45c28
commit 3b67abb0ea
1 changed files with 5 additions and 0 deletions

View File

@ -217,6 +217,7 @@ class Af_RedditImgur extends Plugin {
$found = false;
$post_is_nsfw = false;
$num_comments = 0;
$apply_nsfw_tags = FeedItem_Common::normalize_categories($this->host->get_array($this, "apply_nsfw_tags", []));
// embed before reddit <table> post layout
@ -245,6 +246,8 @@ class Af_RedditImgur extends Plugin {
$data = $child["data"];
$over_18 = $data["over_18"] ?? 0 == 1;
$num_comments += $data["num_comments"] ?? 0;
if ($over_18) {
Debug::log("JSON: post is NSFW", Debug::$LOG_EXTENDED);
$post_is_nsfw = true;
@ -287,6 +290,8 @@ class Af_RedditImgur extends Plugin {
$article["tags"] = array_merge($article["tags"], $apply_nsfw_tags);
}
$article["num_comments"] = $num_comments;
if ($found) {
Debug::log("JSON: found media data, skipping further processing of content", Debug::$LOG_VERBOSE);
$this->remove_post_thumbnail($doc, $xpath);