mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03: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:
parent
bf73372d7f
commit
eb2b4747ae
1 changed files with 7 additions and 1 deletions
|
@ -78,7 +78,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
|||
returnServerError('Channel does not have a community tab');
|
||||
}
|
||||
|
||||
foreach ($this->getCommunityPosts($json) as $post) {
|
||||
foreach ($this->getCommunityPosts($json) as $key => $post) {
|
||||
$this->itemTitle = '';
|
||||
|
||||
if (!isset($post->backstagePostThreadRenderer)) {
|
||||
|
@ -102,6 +102,12 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
|||
$item['content'] .= $this->getAttachments($details);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue