1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-02 22:57:26 +02:00

[YouTubeCommunityTabBridge] Add timestamps (#3477)

As YouTube doesn't provide precise dates for community posts, an
increasing multiple of 60 seconds is subtracted from each timestamp.
This ensures that the original order is always preserved, even if there
are multiple posts with the same date (e.g. "1 month ago").
This commit is contained in:
Thomas
2023-07-02 22:56:08 +02:00
committed by GitHub
parent bf73372d7f
commit eb2b4747ae

View File

@@ -78,7 +78,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
returnServerError('Channel does not have a community tab'); returnServerError('Channel does not have a community tab');
} }
foreach ($this->getCommunityPosts($json) as $post) { foreach ($this->getCommunityPosts($json) as $key => $post) {
$this->itemTitle = ''; $this->itemTitle = '';
if (!isset($post->backstagePostThreadRenderer)) { if (!isset($post->backstagePostThreadRenderer)) {
@@ -102,6 +102,12 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
$item['content'] .= $this->getAttachments($details); $item['content'] .= $this->getAttachments($details);
$item['title'] = $this->itemTitle; $item['title'] = $this->itemTitle;
$date = strtotime(str_replace(' (edited)', '', $details->publishedTimeText->runs[0]->text));
if (is_int($date)) {
// subtract an increasing multiple of 60 seconds to always preserve the original order
$item['timestamp'] = $date - $key * 60;
}
$this->items[] = $item; $this->items[] = $item;
} }
} }