Skip to content

Commit

Permalink
Update YoutubePlugin.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Athlon1600 committed Jul 18, 2020
1 parent ce1d5d5 commit 541ee43
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/YoutubePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class YoutubePlugin extends AbstractPlugin
// force old YouTube layout!
public function onBeforeRequest(ProxyEvent $event)
{
$event['request']->headers->set('Cookie', 'PREF=f6=8');
$event['request']->headers->set('User-Agent', 'Opera/7.50 (Windows XP; U)');
//$event['request']->headers->set('Cookie', 'PREF=f6=8');
$event['request']->headers->set('User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
}

public function onCompleted(ProxyEvent $event)
Expand All @@ -23,6 +23,12 @@ public function onCompleted(ProxyEvent $event)
$url = $event['request']->getUrl();
$output = $response->getContent();

// homepage will never work properly. Redirect to trending instead.
if (!preg_match('/(watch|results|feed|channel|ombed|css)/i', $url)) {
$response->headers->set('location', proxify_url("https://www.youtube.com/feed/trending", $url));
return;
}

// remove top banner that's full of ads
$output = Html::remove("#header", $output);

Expand Down

1 comment on commit 541ee43

@BinBashBanana
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Please sign in to comment.