From 3059b1ea805e8c3424eb8e9afa0e13a9ea07fc7e Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sun, 24 Sep 2017 17:23:00 +0200 Subject: [PATCH] [YoutubeBridge] Skip Ads The search might return unrelated videos (Ads) that are inserted between regular search results. This adds a check to skip Ads. Closes #571 --- bridges/YoutubeBridge.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index 37ee7c7..1db0735 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -88,7 +88,8 @@ class YoutubeBridge extends BridgeAbstract { $vid = str_replace('yt:video:', '', $element->find('id', 0)->plaintext); $time = strtotime($element->find('published', 0)->plaintext); - $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); + if(strpos($vid, 'googleads') === false) + $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); } $this->request = $this->ytBridgeFixTitle($xml->find('feed > title', 0)->plaintext); } @@ -104,7 +105,7 @@ class YoutubeBridge extends BridgeAbstract { $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); - if($title != '[Private Video]') { + if($title != '[Private Video]' && strpos($vid, 'googleads') === false) { $this->ytBridgeQueryVideoInfo($vid, $author, $desc, $time); $this->ytBridgeAddItem($vid, $title, $author, $desc, $time); $count++;