Athlon1600 / php-proxy

A web proxy script written in PHP and built as an alternative to Glype.
https://www.php-proxy.com
MIT License
298 stars 158 forks source link

Youtube Video Fail ? #41

Closed markizk closed 7 years ago

markizk commented 7 years ago

When I call a YT Site i get this error

Warning: exec() has been disabled for security reasons in /home/..../src/Plugin/YoutubePlugin.php on line 27

Warning: Invalid argument supplied for foreach() in /home/..../src/Plugin/YoutubePlugin.php on line 38

How can I repair this ?

webaddicto commented 7 years ago

You need to ask to your hosting provider to enable exec() function in your PHP.ini: http://www.queryadmin.com/1588/enable-disable-exec-php/

webaddicto commented 7 years ago

Regarding the second warning about foreach(), you can fix it like this:

Edit the file /src/Plugin/YoutubePlugin.php on line 38 and change it as this:

if($formats) foreach($formats as $vid){

Adding if($formats) will remove the warning message.

markizk commented 7 years ago

Thanks @webaddicto

But there are still problems with Videos from VEVO etc. Is it possible to weite a plug in that replace the video and put the embedded video instead.

Thanks

webaddicto commented 7 years ago

Php-proxy uses youtubedl: https://github.com/rg3/youtube-dl

To get the video URL, see this code from YouTube plugin:

// will return empty if youtube-dl not installed
private function youtube_dl(){

    $result = array();

    $start = microtime(true);

    // --get-url
    // --dump-single-json
    $cmd = sprintf('youtube-dl -J %s', escapeshellarg($this->youtube_url));
    exec($cmd, $output, $ret);

    $end = microtime(true);

    if($ret == 0){

        $json = json_decode($output[0], true);

        // formats
        $formats = $json['formats'];

        foreach($formats as $vid){
            $result[$vid['format_id']] = $vid['url'];
        }
    }

    return $result;
}

So you must have youtubedl installed in your server: http://rg3.github.io/youtube-dl/download.html

Athlon1600 commented 7 years ago

You're using an outdated version of php-proxy. Latest version no longer defaults to youtube-dl for Vevo videos and such.

markizk commented 7 years ago

Is this also possible with the last version of php-proxy-app, because if i visit the vevo videos ther it´s not possible to play. (https://www.youtube.com/watch?v=CevxZvSJLk8&list=PLWRJVI4Oj4IaYIWIpFlnRJ_v_fIaIl6Ey) would not play.

Athlon1600 commented 7 years ago

How do you know that you're using the latest version? This API script uses the latest version and your katty perry video loads fine here: https://api.unblockvideos.com/youtube_downloader?id=CevxZvSJLk8&selector=mp4&redirect=true

you need to manually edit your composer.json file and ask for "dev-master" version instead of 1.0 or 1.1 whatever.