diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php
index 8d739251..d43dd263 100644
--- a/bridges/YoutubeBridge.php
+++ b/bridges/YoutubeBridge.php
@@ -23,9 +23,66 @@ class YoutubeBridge extends BridgeAbstract{
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->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
$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->content = '
' . $item->title . '';
$this->items[] = $item;
diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php
index cdd0a9ad..b9644d0e 100644
--- a/formats/AtomFormat.php
+++ b/formats/AtomFormat.php
@@ -18,17 +18,26 @@ class AtomFormat extends FormatAbstract{
$extraInfos = $this->getExtraInfos();
$title = htmlspecialchars($extraInfos['name']);
$uri = htmlspecialchars($extraInfos['uri']);
-
+ $timestamps = array();
$entries = '';
foreach($this->getDatas() as $data){
+ $attachments = '';
$entryName = is_null($data->name) ? $title : $data->name;
$entryAuthor = is_null($data->author) ? $uri : $data->author;
$entryTitle = is_null($data->title) ? '' : $data->title;
$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.
$entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
-
+ foreach ($entryAttachments as $key => $attachment){
+ $url = $attachment["URL"];
+ $codec = $attachment["codec"];
+ $attachments .= <<
+EOD;
+ }
$entries .= <<
@@ -41,10 +50,12 @@ class AtomFormat extends FormatAbstract{
{$entryUri}
{$entryTimestamp}
{$entryContent}
+ {$attachments}
EOD;
}
+ $update_timestamp = date(DATE_ATOM, max($timestamps));
/*
TODO :
@@ -60,7 +71,7 @@ EOD;
{$title}
http{$https}://{$httpHost}{$httpInfo}/
-
+ {$update_timestamp}
{$entries}