Athlon1600 / php-proxy-app

Web Proxy Application built on php-proxy library ready to be installed on your server
https://www.php-proxy.com/
MIT License
823 stars 516 forks source link

Dont Work YouTube #183

Closed KUNKUN2121 closed 4 years ago

KUNKUN2121 commented 4 years ago

When I try to watch YouTube, it says "Please update your browser" and cannot be displayed even if you press "Notify me later"

390 392

ch4rc0al1080 commented 4 years ago

haha, I have found the solution

wapfalls commented 4 years ago

haha, I have found the solution

Am also facing the same issue. How did you manage to fix it?

ch4rc0al1080 commented 4 years ago

haha, I have found the solution

Am also facing the same issue. How did you manage to fix it?

actually it comes from reddit

just delete the cookie setting and made the ua like you are a google bot

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

@Athlon1600 please fix it, I can not pr now

benjaminlammers commented 4 years ago

haha, I have found the solution

Am also facing the same issue. How did you manage to fix it?

actually it comes from reddit

just delete the cookie setting and made the ua like you are a google bot

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

@Athlon1600 please fix it, I can not pr now

Can you elaborate on how you fixed the issue? I'm having the same problem

MapGuy11 commented 4 years ago

Still Broken Above User-Agent Doesn't Work

ch4rc0al1080 commented 4 years ago

It broke again...I have found it...

ch4rc0al1080 commented 4 years ago

OK I likely fixed it, but it still has some limits First, make it like this

// force old YouTube layout!
    public function onBeforeRequest(ProxyEvent $event)
    {
        //$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)');
    }

This will fix the layout in video pages etc.

Then like this

//in onCompleted function
$url = $event['request']->getUrl();
        if( (!preg_match('/watch/',$url)) && (!preg_match('/results/',$url)) && (!preg_match('/feed/',$url)) && (!preg_match('/channel/',$url)) && (!preg_match('/ombed/',$url)) && (!preg_match('/css/',$url)) ) //if in the homepage
            die(header('location:index.php?q=https%3A%2F%2Fwww.youtube.com%2Ffeed%2Ftrending')); //only in url mode 0 , if you want to use it in other mode, try to post url to index.php

This code will direct users to the feed page which works well...

MapGuy11 commented 4 years ago

Nevermind Got It To Work thanks! One Question Do You get 720P YouTube on your proxy when setting the resolution?

BinBashBanana commented 4 years ago

Thanks so much!

ch4rc0al1080 commented 4 years ago

Nevermind Got It To Work thanks! One Question Do You get 720P YouTube on your proxy when setting the resolution?

I replaced 480 with 720, It seems has a better quality...I'm not sure

ch4rc0al1080 commented 4 years ago

According to the code, It seems has a priority in finding the video urls... so it might just find a .mp4 format video ...

Athlon1600 commented 4 years ago

@kinglyl 's solution appears to be working. We're giving up on trying to make homepage load, and redirecting straight to trending page. https://github.com/Athlon1600/php-proxy-plugin-bundle/commit/541ee4376e8d59fe5ca1b712e61a522fbf4c13b6

Now just do composer update and it should work, because it already works on here: https://unblockvideos.com/

you'd have to change the logic here: https://github.com/Athlon1600/php-proxy-plugin-bundle/blob/master/src/YoutubePlugin.php#L62

which currently works by just taking the first video it finds which happens to be 360 rather than 720.

ch4rc0al1080 commented 4 years ago

which currently works by just taking the first video it finds which happens to be 480 rather than 720.

$links = $youtube->getDownloadLinks($url, "mp4 360, mp4");

why 480? why not 360........

Athlon1600 commented 4 years ago

sorry, meant to write 360 not 480. And the reason it default to such low resolution is because back when this was coded in, I had very limited bandwidth and lots of people who were using youtube, so this was the only way to not exceed my monthly bandwidth limits...

ch4rc0al1080 commented 4 years ago

This issue can be closed now

ch4rc0al1080 commented 4 years ago

Holy SH*T Youtube seems not working in old layout again in my site And unblockvideos.com are facing 429 error so I don't know whither it is only my problem or not

ch4rc0al1080 commented 4 years ago

I can see trending page in old layout, but video page is in new now

BinBashBanana commented 4 years ago

Maybe a cache problem? It doesn't work for me.

ch4rc0al1080 commented 4 years ago

I can see trending page in old layout, but video page is in new now

Now I can see video page in old layout but trending page is in new

ch4rc0al1080 commented 4 years ago

It seems Html::remove_scripts() does't work in https://www.youtube.com and https://www.youtube.com/gaming

BinBashBanana commented 4 years ago

Trending page broken!

Athlon1600 commented 4 years ago

I'm aware, but that page on youtube heavily depends on javascript and php-proxy does not parse javascript well. Hopefully I can find a solution to this...

ch4rc0al1080 commented 4 years ago

It seems that the only way to solve the problem is redirect to a specific video page combine PREF and GoogleBot UA

public function onBeforeRequest(ProxyEvent $event)
    {
        $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)');
    }

and

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

So users can open Youtube and find videos in the result page