[bridges] use constants instead of variable members

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-30 11:23:55 +02:00
parent 556b8a2452
commit 9a0da733ef
129 changed files with 834 additions and 834 deletions

View file

@ -8,12 +8,12 @@
*/
class YoutubeBridge extends BridgeAbstract {
public $name = 'YouTube Bridge';
public $uri = 'https://www.youtube.com/';
public $description = 'Returns the 10 newest videos by username/channel/playlist or search';
public $maintainer = 'mitsukarenai';
const NAME = 'YouTube Bridge';
const URI = 'https://www.youtube.com/';
const DESCRIPTION = 'Returns the 10 newest videos by username/channel/playlist or search';
const MAINTAINER = 'mitsukarenai';
public $parameters = array(
const PARAMETERS = array(
'By username' => array(
'u'=>array(
'name'=>'username',
@ -48,7 +48,7 @@ class YoutubeBridge extends BridgeAbstract {
);
private function ytBridgeQueryVideoInfo($vid, &$author, &$desc, &$time) {
$html = $this->getSimpleHTMLDOM($this->uri."watch?v=$vid");
$html = $this->getSimpleHTMLDOM(self::URI."watch?v=$vid");
$author = $html->innertext;
$author = substr($author, strpos($author, '"author=') + 8);
$author = substr($author, 0, strpos($author, '\u0026'));
@ -62,8 +62,8 @@ class YoutubeBridge extends BridgeAbstract {
$item['title'] = $title;
$item['author'] = $author;
$item['timestamp'] = $time;
$item['uri'] = $this->uri.'watch?v='.$vid;
$thumbnailUri = str_replace('/www.', '/img.', $this->uri).'vi/'.$vid.'/0.jpg';
$item['uri'] = self::URI.'watch?v='.$vid;
$thumbnailUri = str_replace('/www.', '/img.', self::URI).'vi/'.$vid.'/0.jpg';
$item['content'] = '<a href="'.$item['uri'].'"><img src="'.$thumbnailUri.'" /></a><br />'.$desc;
$this->items[] = $item;
}
@ -110,12 +110,12 @@ class YoutubeBridge extends BridgeAbstract {
if ($this->getInput('u')) { /* User and Channel modes */
$this->request = $this->getInput('u');
$url_feed = $this->uri.'feeds/videos.xml?user='.urlencode($this->request);
$url_listing = $this->uri.'user/'.urlencode($this->request).'/videos';
$url_feed = self::URI.'feeds/videos.xml?user='.urlencode($this->request);
$url_listing = self::URI.'user/'.urlencode($this->request).'/videos';
} else if ($this->getInput('c')) {
$this->request = $this->getInput('c');
$url_feed = $this->uri.'feeds/videos.xml?channel_id='.urlencode($this->request);
$url_listing = $this->uri.'channel/'.urlencode($this->request).'/videos';
$url_feed = self::URI.'feeds/videos.xml?channel_id='.urlencode($this->request);
$url_listing = self::URI.'channel/'.urlencode($this->request).'/videos';
}
if (!empty($url_feed) && !empty($url_listing)) {
if ($xml = $this->getSimpleHTMLDOM($url_feed)) {
@ -127,7 +127,7 @@ class YoutubeBridge extends BridgeAbstract {
else if ($this->getInput('p')) { /* playlist mode */
$this->request = $this->getInput('p');
$url_listing = $this->uri.'playlist?list='.urlencode($this->request);
$url_listing = self::URI.'playlist?list='.urlencode($this->request);
$html = $this->getSimpleHTMLDOM($url_listing) or $this->returnServerError("Could not request YouTube. Tried:\n - $url_listing");
$this->ytBridgeParseHtmlListing($html, 'tr.pl-video', '.pl-video-title a');
$this->request = 'Playlist: '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext);
@ -135,7 +135,7 @@ class YoutubeBridge extends BridgeAbstract {
else if ($this->getInput('s')) { /* search mode */
$this->request = $this->getInput('s'); $page = 1; if ($this->getInput('pa')) $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('pa'));
$url_listing = $this->uri.'results?search_query='.urlencode($this->request).'&page='.$page.'&filters=video&search_sort=video_date_uploaded';
$url_listing = self::URI.'results?search_query='.urlencode($this->request).'&page='.$page.'&filters=video&search_sort=video_date_uploaded';
$html = $this->getSimpleHTMLDOM($url_listing) or $this->returnServerError("Could not request YouTube. Tried:\n - $url_listing");
$this->ytBridgeParseHtmlListing($html, 'div.yt-lockup', 'h3');
$this->request = 'Search: '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext);