mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
Merge 5e56530861
into 6b9074da2a
This commit is contained in:
commit
c24c3279aa
@ -23,9 +23,66 @@ class YoutubeBridge extends BridgeAbstract{
|
|||||||
|
|
||||||
|
|
||||||
foreach($html->find('li.channels-content-item') as $element) {
|
foreach($html->find('li.channels-content-item') as $element) {
|
||||||
|
|
||||||
|
|
||||||
|
$opts = array('http' =>
|
||||||
|
array(
|
||||||
|
"method" => "GET",
|
||||||
|
'header' => "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\r\n"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$context = stream_context_create($opts);
|
||||||
|
|
||||||
|
$html_video = file_get_contents('http://www.youtube.com'.$element->find('a',0)->href, false, $context);
|
||||||
|
|
||||||
|
if(!preg_match('/stream_map=(.[^&]*?)&/i',$html_video,$match))
|
||||||
|
{
|
||||||
|
//$this->returnError ("Error Locating Downlod URL's", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!preg_match('/stream_map=(.[^&]*?)(?:\\\\|&)/i',$html_video,$match))
|
||||||
|
{
|
||||||
|
//$this->returnError ("Problem", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fmt_url = urldecode($match[1]);
|
||||||
|
|
||||||
|
$urls = explode(',',$fmt_url);
|
||||||
|
|
||||||
|
$videos = array();
|
||||||
|
|
||||||
|
foreach($urls as $url)
|
||||||
|
{
|
||||||
|
if(preg_match('/itag=([0-9]+)/',$url,$tm) && preg_match('/sig=(.*?)&/', $url , $si) && preg_match('/url=(.*?)&/', $url , $um))
|
||||||
|
{
|
||||||
|
$u = urldecode($um[1]);
|
||||||
|
$videos[$tm[1]] = $u.'&signature='.$si[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$codecs = array();
|
||||||
|
$codecs[13] = "video/3gpp";
|
||||||
|
$codecs[17] = "video/3gpp";
|
||||||
|
$codecs[36] = "video/3gpp";
|
||||||
|
$codecs[5] = "video/x-flv";
|
||||||
|
$codecs[6] = "video/x-flv";
|
||||||
|
$codecs[34] = "video/x-flv";
|
||||||
|
$codecs[35] = "video/x-flv";
|
||||||
|
$codecs[43] = "video/webm";
|
||||||
|
$codecs[44] = "video/webm";
|
||||||
|
$codecs[45] = "video/webm";
|
||||||
|
$codecs[18] = "video/mp4";
|
||||||
|
$codecs[22] = "video/mp4";
|
||||||
|
$codecs[37] = "video/mp4";
|
||||||
|
$codecs[33] = "video/mp4";
|
||||||
|
|
||||||
$item = new \Item();
|
$item = new \Item();
|
||||||
$item->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
|
$item->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
|
||||||
$item->thumbnailUri = 'https:'.$element->find('img',0)->src;
|
$item->thumbnailUri = 'https:'.$element->find('img',0)->src;
|
||||||
|
$item->attachments = array();
|
||||||
|
foreach ($videos as $key => $value){
|
||||||
|
$item->attachments[] = array("URL" => htmlspecialchars($value), "codec" => $codecs[$key]);
|
||||||
|
}
|
||||||
$item->title = trim($element->find('h3',0)->plaintext);
|
$item->title = trim($element->find('h3',0)->plaintext);
|
||||||
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>';
|
$item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>';
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
@ -18,17 +18,26 @@ class AtomFormat extends FormatAbstract{
|
|||||||
$extraInfos = $this->getExtraInfos();
|
$extraInfos = $this->getExtraInfos();
|
||||||
$title = htmlspecialchars($extraInfos['name']);
|
$title = htmlspecialchars($extraInfos['name']);
|
||||||
$uri = htmlspecialchars($extraInfos['uri']);
|
$uri = htmlspecialchars($extraInfos['uri']);
|
||||||
|
$timestamps = array();
|
||||||
$entries = '';
|
$entries = '';
|
||||||
foreach($this->getDatas() as $data){
|
foreach($this->getDatas() as $data){
|
||||||
|
$attachments = '';
|
||||||
$entryName = is_null($data->name) ? $title : $data->name;
|
$entryName = is_null($data->name) ? $title : $data->name;
|
||||||
$entryAuthor = is_null($data->author) ? $uri : $data->author;
|
$entryAuthor = is_null($data->author) ? $uri : $data->author;
|
||||||
$entryTitle = is_null($data->title) ? '' : $data->title;
|
$entryTitle = is_null($data->title) ? '' : $data->title;
|
||||||
$entryUri = is_null($data->uri) ? '' : $data->uri;
|
$entryUri = is_null($data->uri) ? '' : $data->uri;
|
||||||
$entryTimestamp = is_null($data->timestamp) ? '' : date(DATE_ATOM, $data->timestamp);
|
$entryAttachments = is_null($data->attachments) ? array() : $data->attachments;
|
||||||
|
$entryTimestamp = is_null($data->timestamp) ? date(DATE_ATOM, 0) : date(DATE_ATOM, $data->timestamp);
|
||||||
|
$timestamps[] = (int)$entryTimestamp;
|
||||||
// We prevent content from closing the CDATA too early.
|
// We prevent content from closing the CDATA too early.
|
||||||
$entryContent = is_null($data->content) ? '' : '<![CDATA[' . $this->sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
|
$entryContent = is_null($data->content) ? '' : '<![CDATA[' . $this->sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
|
||||||
|
foreach ($entryAttachments as $key => $attachment){
|
||||||
|
$url = $attachment["URL"];
|
||||||
|
$codec = $attachment["codec"];
|
||||||
|
$attachments .= <<<EOD
|
||||||
|
<link rel="enclosure" href="{$url}" type="{$codec}" />
|
||||||
|
EOD;
|
||||||
|
}
|
||||||
$entries .= <<<EOD
|
$entries .= <<<EOD
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
@ -41,10 +50,12 @@ class AtomFormat extends FormatAbstract{
|
|||||||
<id>{$entryUri}</id>
|
<id>{$entryUri}</id>
|
||||||
<updated>{$entryTimestamp}</updated>
|
<updated>{$entryTimestamp}</updated>
|
||||||
<content type="html">{$entryContent}</content>
|
<content type="html">{$entryContent}</content>
|
||||||
|
{$attachments}
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
}
|
}
|
||||||
|
$update_timestamp = date(DATE_ATOM, max($timestamps));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO :
|
TODO :
|
||||||
@ -60,7 +71,7 @@ EOD;
|
|||||||
|
|
||||||
<title type="text">{$title}</title>
|
<title type="text">{$title}</title>
|
||||||
<id>http{$https}://{$httpHost}{$httpInfo}/</id>
|
<id>http{$https}://{$httpHost}{$httpInfo}/</id>
|
||||||
<updated></updated>
|
<updated>{$update_timestamp}</updated>
|
||||||
<link rel="alternate" type="text/html" href="{$uri}" />
|
<link rel="alternate" type="text/html" href="{$uri}" />
|
||||||
<link rel="self" href="http{$https}://{$httpHost}{$serverRequestUri}" />
|
<link rel="self" href="http{$https}://{$httpHost}{$serverRequestUri}" />
|
||||||
{$entries}
|
{$entries}
|
||||||
|
Loading…
Reference in New Issue
Block a user