Permalink
Browse files

Search also in adaptive format for a specific itag

fixes #274
  • Loading branch information...
Art4 committed Oct 14, 2017
1 parent 2aa53b7 commit ef64b2bef706156649130c2d7397081f8d31bf2a
Showing with 10 additions and 9 deletions.
  1. +8 −9 src/Application/ResultController.php
  2. +2 −0 templates/getvideo.php
@@ -181,6 +181,7 @@ public function execute()
'direct_url' => $directlink,
'proxy_url' => $proxylink,
'type' => $avail_format->getType(),
'itag' => $avail_format->getItag(),
'quality' => $avail_format->getQuality(),
'size' => $this->formatBytes($size),
];
@@ -203,6 +204,7 @@ public function execute()
'direct_url' => $directlink,
'proxy_url' => $proxylink,
'type' => $avail_format->getType(),
'itag' => $avail_format->getItag(),
'quality' => $avail_format->getQuality(),
'size' => $this->formatBytes($size),
];
@@ -263,18 +265,17 @@ private function getDownloadUrlByFormat(VideoInfo $video_info, $format)
}
/* Now we need to find our best format in the list of available formats */
$best_format = '';
$best_format = null;
$avail_formats = $video_info->getFormats();
$avail_formats = $video_info->getFormats() + $video_info->getAdaptiveFormats();
for ($i = 0; $i < count($target_formats); $i++)
foreach ( $target_formats as $target_format )
{
for ($j = 0; $j < count($avail_formats); $j++)
foreach ( $avail_formats as $format )
{
$format = $avail_formats[$j];
if ($target_formats[$i] == $format->getItag())
if ($target_format == $format->getItag())
{
$best_format = $j;
$best_format = $format;
break 2;
}
}
@@ -287,8 +288,6 @@ private function getDownloadUrlByFormat(VideoInfo $video_info, $format)
return null;
}
$best_format = $avail_formats[$best_format];
$redirect_url = $best_format->getUrl();
if ( ! empty($redirect_url) )
View
@@ -38,6 +38,7 @@
<a class="btn btn-primary btn-download" href="<?php echo $format['proxy_url']; ?>" class="mime"><i class="glyphicon glyphicon-download-alt"></i> Proxy</a>
<?php } ?>
<div class="label label-warning"><?php echo $format['size']; ?></div>
<div class="label label-default"><?php echo $format['itag']; ?></div>
</li>
<?php } ?>
</ul>
@@ -54,6 +55,7 @@
<a class="btn btn-primary btn-download" href="<?php echo $format['proxy_url']; ?>" class="mime"><i class="glyphicon glyphicon-download-alt"></i> Proxy</a>
<?php } ?>
<div class="label label-warning"><?php echo $format['size']; ?></div>
<div class="label label-default"><?php echo $format['itag']; ?></div>
</li>
<?php } ?>
</ul>

0 comments on commit ef64b2b

Please sign in to comment.