mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-26 19:36:52 +03:00
[pull] Fix Youtube, Twitter
This commit is contained in:
parent
e81a19a04b
commit
1e40d6f492
2 changed files with 16 additions and 12 deletions
|
@ -26,15 +26,15 @@ class TwitterBridge extends BridgeAbstract{
|
|||
$this->returnError('You must specify a keyword (?q=...) or a Twitter username (?u=...).', 400);
|
||||
}
|
||||
|
||||
foreach($html->find('div.tweet') as $tweet) {
|
||||
foreach($html->find('div.js-stream-tweet') as $tweet) {
|
||||
$item = new \Item();
|
||||
$item->username = trim(substr($tweet->find('span.username', 0)->plaintext, 1)); // extract username and sanitize
|
||||
$item->username = $tweet->getAttribute('data-screen-name'); // extract username and sanitize
|
||||
$item->fullname = $tweet->getAttribute('data-name'); // extract fullname (pseudonym)
|
||||
$item->avatar = $tweet->find('img', 0)->src; // get avatar link
|
||||
$item->id = $tweet->getAttribute('data-tweet-id'); // get TweetID
|
||||
$item->uri = 'https://twitter.com'.$tweet->find('a.details', 0)->getAttribute('href'); // get tweet link
|
||||
$item->timestamp = $tweet->find('span._timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp
|
||||
$item->content = str_replace('href="/', 'href="https://twitter.com/', strip_tags($tweet->find('p.tweet-text', 0)->innertext, '<a>')); // extract tweet text
|
||||
$item->uri = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); // get tweet link
|
||||
$item->timestamp = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp
|
||||
$item->content = str_replace('href="/', 'href="https://twitter.com/', strip_tags($tweet->find('p.js-tweet-text', 0)->innertext, '<a>')); // extract tweet text
|
||||
$item->title = $item->fullname . ' (@'. $item->username . ') | ' . $item->content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
* @use1(u="username")
|
||||
* @use2(p="playlist id")
|
||||
* @use3(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);
|
||||
* into: define('MAX_FILE_SIZE', 900000); (or more)
|
||||
*/
|
||||
class YoutubeBridge extends BridgeAbstract{
|
||||
|
||||
|
@ -32,21 +36,21 @@ class YoutubeBridge extends BridgeAbstract{
|
|||
$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);
|
||||
|
||||
foreach($html->find('li.playlist-video-item') as $element) {
|
||||
foreach($html->find('tr.pl-video') as $element) {
|
||||
$item = new \Item();
|
||||
$item->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
|
||||
$item->thumbnailUri = 'https:'.$element->find('img',0)->src;
|
||||
$item->title = trim($element->find('h3',0)->plaintext);
|
||||
$item->uri = 'https://www.youtube.com'.$element->find('.pl-video-title a',0)->href;
|
||||
$item->thumbnailUri = 'https:'.str_replace('/default.','/mqdefault.',$element->find('.pl-video-thumbnail img',0)->src);
|
||||
$item->title = trim($element->find('.pl-video-title a',0)->plaintext);
|
||||
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>';
|
||||
$this->items[] = $item;
|
||||
}
|
||||
$this->request = 'Playlist '.str_replace(' - YouTube', '', $html->find('title', 0)->plaintext).', by '.$html->find('h1', 0)->plaintext;
|
||||
$this->request = 'Playlist '.trim(str_replace(' - YouTube', '', $html->find('title', 0)->plaintext)).', by '.$html->find('h1', 0)->plaintext;
|
||||
}
|
||||
else if (isset($param['s'])) { /* search mode */
|
||||
$this->request = $param['s']; $page = 1; if (isset($param['pa'])) $page = (int)preg_replace("/[^0-9]/",'', $param['pa']);
|
||||
$html = file_get_html('https://www.youtube.com/results?search_query='.urlencode($this->request).'&page='.$page.'&filters=video&search_sort=video_date_uploaded') or $this->returnError('Could not request Youtube.', 404);
|
||||
$html = file_get_html('https://www.youtube.com/results?search_query='.urlencode($this->request).'&&page='.$page.'&filters=video&search_sort=video_date_uploaded') or $this->returnError('Could not request Youtube.', 404);
|
||||
|
||||
foreach($html->find('li.context-data-item') as $element) {
|
||||
foreach($html->find('li.yt-lockup') as $element) {
|
||||
$item = new \Item();
|
||||
$item->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
|
||||
$checkthumb = $element->find('img', 0)->getAttribute('data-thumb');
|
||||
|
|
Loading…
Reference in a new issue