[YoutubeBridge] Fix playlist mode (#876)

* Corrected duration text selector
* Request YouTube page with English localization
* Filter video items in the beginning of the loop
This commit is contained in:
Eugene Molotov 2018-10-20 15:43:48 +05:00 committed by LogMANOriginal
parent afd5ef0f1d
commit 87d218296e

View file

@ -147,12 +147,19 @@ class YoutubeBridge extends BridgeAbstract {
$time = 0;
$vid = str_replace('/watch?v=', '', $element->find('a', 0)->href);
$vid = substr($vid, 0, strpos($vid, '&') ?: strlen($vid));
$title = $this->ytBridgeFixTitle($element->find($title_selector, 0)->plaintext);
$title = trim($this->ytBridgeFixTitle($element->find($title_selector, 0)->plaintext));
if (strpos($vid, 'googleads') !== false
|| $title == '[Private video]'
|| $title == '[Deleted video]'
) {
continue;
}
// The duration comes in one of the formats:
// hh:mm:ss / mm:ss / m:ss
// 01:03:30 / 15:06 / 1:24
$durationText = trim($element->find('span[class="video-time"]', 0)->plaintext);
$durationText = trim($element->find('div.timestamp span', 0)->plaintext);
$durationText = preg_replace('/([\d]{1,2})\:([\d]{2})/', '00:$1:$2', $durationText);
sscanf($durationText, '%d:%d:%d', $hours, $minutes, $seconds);
@ -162,7 +169,6 @@ class YoutubeBridge extends BridgeAbstract {
continue;
}
if($title != '[Private Video]' && strpos($vid, 'googleads') === false) {
if ($add_parsed_items) {
$this->ytBridgeQueryVideoInfo($vid, $author, $desc, $time);
$this->ytBridgeAddItem($vid, $title, $author, $desc, $time);
@ -170,7 +176,6 @@ class YoutubeBridge extends BridgeAbstract {
$count++;
}
}
}
return $count;
}
@ -181,7 +186,9 @@ class YoutubeBridge extends BridgeAbstract {
private function ytGetSimpleHTMLDOM($url){
return getSimpleHTMLDOM($url,
$header = array(),
$header = array(
'Accept-Language: en-US'
),
$opts = array(),
$lowercase = true,
$forceTagsClosed = true,