mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-22 22:46:53 +00:00
Attaching the mp4 file to youtube feed
This commit is contained in:
parent
b866fb74c0
commit
ea0b38ad4a
@ -23,9 +23,49 @@ 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);
|
||||||
|
|
||||||
|
$foundArray = 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]);
|
||||||
|
$foundArray[$tm[1]] = $u.'&signature='.$si[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print_r($foundarray);
|
||||||
|
$video = $foundArray[22];
|
||||||
|
|
||||||
$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->attachment = htmlspecialchars($video);
|
||||||
$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;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Atom
|
* Atom
|
||||||
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
|
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
|
||||||
@ -25,6 +25,7 @@ class AtomFormat extends FormatAbstract{
|
|||||||
$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;
|
||||||
|
$entryAttachment = is_null($data->attachment) ? '' : $data->attachment;
|
||||||
$entryTimestamp = is_null($data->timestamp) ? '' : date(DATE_ATOM, $data->timestamp);
|
$entryTimestamp = is_null($data->timestamp) ? '' : date(DATE_ATOM, $data->timestamp);
|
||||||
// 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)) . ']]>';
|
||||||
@ -41,6 +42,7 @@ 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>
|
||||||
|
<link rel="enclosure" href="{$entryAttachment}" />
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
Loading…
Reference in New Issue
Block a user