diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php
index d21cc207..98abb26f 100644
--- a/bridges/YoutubeBridge.php
+++ b/bridges/YoutubeBridge.php
@@ -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 = '
' . $item->title . '';
+ $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(){