File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ class YoutubePlugin extends AbstractPlugin
1313 // force old YouTube layout!
1414 public function onBeforeRequest (ProxyEvent $ event )
1515 {
16- $ event ['request ' ]->headers ->set ('Cookie ' , 'PREF=f6=8 ' );
17- $ event ['request ' ]->headers ->set ('User-Agent ' , 'Opera/7.50 (Windows XP; U ) ' );
16+ // $event['request']->headers->set('Cookie', 'PREF=f6=8');
17+ $ event ['request ' ]->headers ->set ('User-Agent ' , 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html ) ' );
1818 }
1919
2020 public function onCompleted (ProxyEvent $ event )
@@ -23,6 +23,12 @@ public function onCompleted(ProxyEvent $event)
2323 $ url = $ event ['request ' ]->getUrl ();
2424 $ output = $ response ->getContent ();
2525
26+ // homepage will never work properly. Redirect to trending instead.
27+ if (!preg_match ('/(watch|results|feed|channel|ombed|css)/i ' , $ url )) {
28+ $ response ->headers ->set ('location ' , proxify_url ("https://www.youtube.com/feed/trending " , $ url ));
29+ return ;
30+ }
31+
2632 // remove top banner that's full of ads
2733 $ output = Html::remove ("#header " , $ output );
2834
You can’t perform that action at this time.
0 commit comments