forked from blallo/rss-bridge
[Youtube] Add channel support (issue #90)
This commit is contained in:
parent
2ed0da8cf0
commit
67338051e7
1 changed files with 25 additions and 4 deletions
|
@ -5,12 +5,13 @@
|
|||
*
|
||||
* @name Youtube Bridge
|
||||
* @homepage https://www.youtube.com/
|
||||
* @description Returns the 10 newest videos by username/playlist or search
|
||||
* @description Returns the 10 newest videos by username/channel/playlist or search
|
||||
* @maintainer mitsukarenai
|
||||
* @update 2014-06-20
|
||||
* @use1(u="username")
|
||||
* @use2(p="playlist id")
|
||||
* @use3(s="search keyword",pa="page")
|
||||
* @use2(c="channel id")
|
||||
* @use3(p="playlist id")
|
||||
* @use4(s="search keyword",pa="page")
|
||||
*
|
||||
* WARNING: to parse big playlists (over ~90 videos), you need to edit simple_html_dom.php:
|
||||
* change: define('MAX_FILE_SIZE', 600000);
|
||||
|
@ -54,6 +55,26 @@ class YoutubeBridge extends BridgeAbstract{
|
|||
}
|
||||
}
|
||||
|
||||
else if (isset($param['c'])) { /* channel timeline mode */
|
||||
$this->request = $param['c'];
|
||||
$html = file_get_html('https://www.youtube.com/channel/'.urlencode($this->request).'/videos') or $this->returnError('Could not request Youtube.', 404);
|
||||
|
||||
foreach($html->find('li.channels-content-item') as $element) {
|
||||
if($count < $limit) {
|
||||
$item = new \Item();
|
||||
$videoquery = parse_url($element->find('a',0)->href, PHP_URL_QUERY); parse_str($videoquery, $videoquery);
|
||||
$item->id = $videoquery['v'];
|
||||
$item->uri = 'https://www.youtube.com/watch?v='.$item->id;
|
||||
$item->thumbnailUri = 'https:'.$element->find('img',0)->src;
|
||||
$item->title = trim($element->find('h3',0)->plaintext);
|
||||
$item->timestamp = getPublishDate($item->id);
|
||||
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>';
|
||||
$this->items[] = $item;
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (isset($param['p'])) { /* playlist mode */
|
||||
$this->request = $param['p'];
|
||||
$html = file_get_html('https://www.youtube.com/playlist?list='.urlencode($this->request).'') or $this->returnError('Could not request Youtube.', 404);
|
||||
|
@ -95,7 +116,7 @@ class YoutubeBridge extends BridgeAbstract{
|
|||
$this->request = 'Search: '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext);
|
||||
}
|
||||
else
|
||||
$this->returnError('You must either specify a Youtube username (?u=...) or a playlist id (?p=...) or search (?s=...)', 400);
|
||||
$this->returnError('You must either specify a Youtube username (?u=...) or a channel id (?c=...) or a playlist id (?p=...) or search (?s=...)', 400);
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
|
|
Loading…
Reference in a new issue