mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-19 08:48:27 +02:00
youtube community posts are just called "Posts" now
This commit is contained in:
parent
354cea09a7
commit
c3c52040f6
1 changed files with 19 additions and 19 deletions
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
class YouTubeCommunityTabBridge extends BridgeAbstract
|
class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
const NAME = 'YouTube Community Tab Bridge';
|
const NAME = 'YouTube Posts Tab Bridge';
|
||||||
const URI = 'https://www.youtube.com';
|
const URI = 'https://www.youtube.com';
|
||||||
const DESCRIPTION = 'Returns posts from a channel\'s community tab';
|
const DESCRIPTION = 'Returns posts from a channel\'s posts tab';
|
||||||
const MAINTAINER = 'VerifiedJoseph';
|
const MAINTAINER = 'VerifiedJoseph';
|
||||||
const PARAMETERS = [
|
const PARAMETERS = [
|
||||||
'By channel ID' => [
|
'By channel ID' => [
|
||||||
|
@ -31,7 +31,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
private $feedName = '';
|
private $feedName = '';
|
||||||
private $itemTitle = '';
|
private $itemTitle = '';
|
||||||
|
|
||||||
private $urlRegex = '/youtube\.com\/(channel|user|c)\/([\w]+)\/community/';
|
private $urlRegex = '/youtube\.com\/(channel|user|c)\/([\w]+)\/posts/';
|
||||||
private $jsonRegex = '/var ytInitialData = ([^<]*);<\/script>/';
|
private $jsonRegex = '/var ytInitialData = ([^<]*);<\/script>/';
|
||||||
|
|
||||||
public function detectParameters($url)
|
public function detectParameters($url)
|
||||||
|
@ -59,14 +59,14 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
{
|
{
|
||||||
if (is_null($this->getInput('username')) === false) {
|
if (is_null($this->getInput('username')) === false) {
|
||||||
try {
|
try {
|
||||||
$this->feedUrl = $this->buildCommunityUri($this->getInput('username'), 'c');
|
$this->feedUrl = $this->buildPostsUri($this->getInput('username'), 'c');
|
||||||
$html = getSimpleHTMLDOM($this->feedUrl);
|
$html = getSimpleHTMLDOM($this->feedUrl);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->feedUrl = $this->buildCommunityUri($this->getInput('username'), 'user');
|
$this->feedUrl = $this->buildPostsUri($this->getInput('username'), 'user');
|
||||||
$html = getSimpleHTMLDOM($this->feedUrl);
|
$html = getSimpleHTMLDOM($this->feedUrl);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->feedUrl = $this->buildCommunityUri($this->getInput('channel'), 'channel');
|
$this->feedUrl = $this->buildPostsUri($this->getInput('channel'), 'channel');
|
||||||
$html = getSimpleHTMLDOM($this->feedUrl);
|
$html = getSimpleHTMLDOM($this->feedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
|
|
||||||
$this->feedName = $json->header->c4TabbedHeaderRenderer->title;
|
$this->feedName = $json->header->c4TabbedHeaderRenderer->title;
|
||||||
|
|
||||||
if ($this->hasCommunityTab($json) === false) {
|
if ($this->hasPostsTab($json) === false) {
|
||||||
returnServerError('Channel does not have a community tab');
|
returnServerError('Channel does not have a posts tab');
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts = $this->getCommunityPosts($json);
|
$posts = $this->getPosts($json);
|
||||||
foreach ($posts as $key => $post) {
|
foreach ($posts as $key => $post) {
|
||||||
$this->itemTitle = '';
|
$this->itemTitle = '';
|
||||||
|
|
||||||
|
@ -132,18 +132,18 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
if (!empty($this->feedName)) {
|
if (!empty($this->feedName)) {
|
||||||
return $this->feedName . ' - YouTube Community Tab';
|
return $this->feedName . ' - YouTube Posts Tab';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Community URI
|
* Build Posts URI
|
||||||
*/
|
*/
|
||||||
private function buildCommunityUri($value, $type)
|
private function buildPostsUri($value, $type)
|
||||||
{
|
{
|
||||||
return self::URI . '/' . $type . '/' . $value . '/community';
|
return self::URI . '/' . $type . '/' . $value . '/posts';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,14 +165,14 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if channel has a community tab
|
* Check if channel has a posts tab
|
||||||
*/
|
*/
|
||||||
private function hasCommunityTab($json)
|
private function hasPostsTab($json)
|
||||||
{
|
{
|
||||||
foreach ($json->contents->twoColumnBrowseResultsRenderer->tabs as $tab) {
|
foreach ($json->contents->twoColumnBrowseResultsRenderer->tabs as $tab) {
|
||||||
if (
|
if (
|
||||||
isset($tab->tabRenderer)
|
isset($tab->tabRenderer)
|
||||||
&& str_ends_with($tab->tabRenderer->endpoint->commandMetadata->webCommandMetadata->url, 'community')
|
&& str_ends_with($tab->tabRenderer->endpoint->commandMetadata->webCommandMetadata->url, 'posts')
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -182,14 +182,14 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get community tab posts
|
* Get posts from posts tab
|
||||||
*/
|
*/
|
||||||
private function getCommunityPosts($json)
|
private function getPosts($json)
|
||||||
{
|
{
|
||||||
foreach ($json->contents->twoColumnBrowseResultsRenderer->tabs as $tab) {
|
foreach ($json->contents->twoColumnBrowseResultsRenderer->tabs as $tab) {
|
||||||
if (
|
if (
|
||||||
isset($tab->tabRenderer)
|
isset($tab->tabRenderer)
|
||||||
&& str_ends_with($tab->tabRenderer->endpoint->commandMetadata->webCommandMetadata->url, 'community')
|
&& str_ends_with($tab->tabRenderer->endpoint->commandMetadata->webCommandMetadata->url, 'posts')
|
||||||
) {
|
) {
|
||||||
return $tab->tabRenderer->content->sectionListRenderer->contents[0]->itemSectionRenderer->contents;
|
return $tab->tabRenderer->content->sectionListRenderer->contents[0]->itemSectionRenderer->contents;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue