Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bascoder committed Mar 26, 2016
1 parent fd201e2 commit 48d9a60
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions youtube-dl.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ private function get_videodata($str)
$pb_info = self::get_public_info();

if($pb_info !== FALSE) {
$htmlTitle = htmlentities(utf8_decode($pb_info["title"]));
//https://github.com/eyecatchup/php-yt_downloader/issues/10#issuecomment-117083347
$htmlTitle = htmlentities(utf8_decode($pb_info["title"]), ENT_QUOTES | ENT_IGNORE, "UTF-8");
$videoTitle = self::canonicalize($htmlTitle);
}
else {
Expand All @@ -492,6 +493,9 @@ private function get_videodata($str)
*/
private function get_url_map($data)
{
//https://github.com/eyecatchup/php-yt_downloader/issues/7
$videos = false;

preg_match('/stream_map=(.[^&]*?)&/i',$data,$match);
if(!isset($match[1])) {
return FALSE;
Expand All @@ -505,11 +509,18 @@ private function get_url_map($data)
$urls = explode(',',$fmt_url);
$tmp = array();

//https://github.com/eyecatchup/php-yt_downloader/issues/10#issuecomment-147021789
foreach($urls as $url) {
if(preg_match('/itag=([0-9]+)&url=(.*?)&.*?/si',$url,$um))
{
$u = urldecode($um[2]);
$tmp[$um[1]] = $u;
$lines = explode('&',$url);
$num = '';
$url = '';
foreach($lines as $u){
$num = ((empty($num)) && (preg_match("/itag=/i",$u))) ? str_replace("itag=","",$u):$num;
$url = ((empty($url)) && (preg_match("/url=/i",$u))) ? str_replace("url=","",$u):$url;
if((!empty($url)) && ((!empty($num)))){
$tmp[$num] = urldecode($url);
break;
}
}
}

Expand Down Expand Up @@ -573,7 +584,8 @@ private function formattedVideoTitle($str)

$title = explode("&", $matches[1][0]);
$title = $title[0];
$title = htmlentities(utf8_decode($title));
//https://github.com/eyecatchup/php-yt_downloader/issues/10#issuecomment-117083347
$title = htmlentities(utf8_decode($title), ENT_QUOTES | ENT_IGNORE, "UTF-8");

return self::canonicalize($title);
}
Expand Down

0 comments on commit 48d9a60

Please sign in to comment.