Kallys / MediaDownloader

A WebUI for youtube-dl, implementing management for background downloads (queuing, concurrency...)
Other
75 stars 17 forks source link

Says youtube-dl is not installed. #3

Closed aidinzolghadr closed 7 years ago

aidinzolghadr commented 7 years ago

Hi,

It says youtube-dl is not installed but it is and I can run it via terminal. Also "which " is installed and "which youtube-dl" returns correct path but still the check in line #130 of Downloader.php in lib returns false.

I even commented it out as I'm sure it is not necessary (not a good approach but I need to get it working fast) but it sill won't work. When I put a URL and press download, it reloads and does nothing, nothing in the download jobs either.

Thanks.

Kallys commented 7 years ago

Hi !

First thing I'm thinking of : file permissions. Is youtube-dl available for user www-data (or your equivalent) ? Usually :

> which youtube-dl 
youtube-dl is /usr/local/bin/youtube-dl
> ls -l /usr/local/bin/youtube-dl
-rwxr-xr-x 1 root root 1,4M nov.   2 21:02 /usr/local/bin/youtube-dl

Otherwise, what is your PHP version ?

aidinzolghadr commented 7 years ago

Hi,

Thanks for the reply. I own a shared host so I had to install it in a custom directory and add it to PATH (Not sure if I've done this correctly).

When I run the which command via terminal, it returns the correct path it is installed.

But when I execute it via PHP, it may not get executed.

I thought maybe exec() is banned on my server but it is not.

I've tried several other variations and forks of this web UI that you forked from, same results.

My PHP version was 5 and I upgraded to 7.0 in hope for a solution but it did not change anything. I can downgrade too.

My Python is 2.7.9.

Best, Idn

On Jan 11, 2017 12:37 PM, "Kallys" notifications@github.com wrote:

Hi !

First thing I'm thinking of : file permissions. Is youtube-dl available for user www-data (or your equivalent) ? Usually :

which youtube-dl youtube-dl is /usr/local/bin/youtube-dl ls -l /usr/local/bin/youtube-dl -rwxr-xr-x 1 root root 1,4M nov. 2 21:02 /usr/local/bin/youtube-dl

Otherwise, what is your PHP version ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kallys/MediaDownloader/issues/3#issuecomment-271815466, or mute the thread https://github.com/notifications/unsubscribe-auth/AF8vqlwmjpvPkkoDf5Hb1AbeZF9DeFaMks5rRJvbgaJpZM4LgEsP .

aidinzolghadr commented 7 years ago

I don't understand the last lines of code that you posted re permission but I did run chmod 775 on downloads folder, on all folders, 644 on all files, different combinations, no luck.

Problem is I can't see an error log. My host is 1and1 and it says to put a PHP.ini file in the root of my program with some stuff but it does not generate an error.

Thanks

On Jan 11, 2017 2:32 PM, "Aidin Zolghadr" aidinz@gmail.com wrote:

Hi,

Thanks for the reply. I own a shared host so I had to install it in a custom directory and add it to PATH (Not sure if I've done this correctly).

When I run the which command via terminal, it returns the correct path it is installed.

But when I execute it via PHP, it may not get executed.

I thought maybe exec() is banned on my server but it is not.

I've tried several other variations and forks of this web UI that you forked from, same results.

My PHP version was 5 and I upgraded to 7.0 in hope for a solution but it did not change anything. I can downgrade too.

My Python is 2.7.9.

Best, Idn

On Jan 11, 2017 12:37 PM, "Kallys" notifications@github.com wrote:

Hi !

First thing I'm thinking of : file permissions. Is youtube-dl available for user www-data (or your equivalent) ? Usually :

which youtube-dl youtube-dl is /usr/local/bin/youtube-dl ls -l /usr/local/bin/youtube-dl -rwxr-xr-x 1 root root 1,4M nov. 2 21:02 /usr/local/bin/youtube-dl

Otherwise, what is your PHP version ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kallys/MediaDownloader/issues/3#issuecomment-271815466, or mute the thread https://github.com/notifications/unsubscribe-auth/AF8vqlwmjpvPkkoDf5Hb1AbeZF9DeFaMks5rRJvbgaJpZM4LgEsP .

Kallys commented 7 years ago

I think the issue is either youtube-dl is not executable for your php user, or, has you said, exec() is restricted on your host.

  1. Make sure youtuble-dl is readable and executable for everyone (chmod a+rx path/to/youtube-dl)
  2. Try to make php executing a basic command : Create a new file 'whoami.php' at the root of your project. Set right permissions to this file (chmod a+r path/to/whoami.php) Insert the following code into this file :
    <?php
    echo exec('whoami');
    ?>

    Browse to the corresponding URL path using your web browser (http://your_domain/path/to/webroot/whoami.php).

aidinzolghadr commented 7 years ago

Exec() works fine, tested before (I was not clear enough).

I did the chmod on youtube-dl directory but still says youtube-dl is not installed. Probably the which command does not return true and perhaps problem is with exec? or the user? But I call exec via browser and works fine.

I have one other possibility, maybe youtube-dl is not in path of apache and thus not visible to it. I added it to bashc I think to make it work via terminal.

Kallys commented 7 years ago

And what about sudo -u www-data which youtube-dl or sudo -u www-data youtube-dl ? (I assume your PHP user is www-data, adapt previous line otherwise)

You could also check if your path to youtube-dl is in PHP Environment PATH variable by displaying PHP infos.

<?php
phpinfo();
?>
aidinzolghadr commented 7 years ago

1) I don't have root access and don't have sudo nor can install it. Any other way to run that command?

2) PHP version was NOT 7 but 5.3, updated to 7.

3) I ran phpinfo() and it did not had any "youtube-dl" in it.

Thank you for your persistent care.

Kallys commented 7 years ago

You shouldn't see directly youtube-dl inside phpinfo() ; but be sure youtube-dl directory is listed inside PATH variable.

For example, mine is : phpinfo()'s PATH is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" And youtube-dl path is "/usr/local/bin/youtube-dl"

aidinzolghadr commented 7 years ago

No it doesn't contain my youtube-dl's parent directory. My PATH is just /bin:/usr/bin Which I think is default and I probably can't change. I've read that I can put a php.ini inside the folder of the project with a include_path line and static address of youtube-dl, but it didn't work as well.

aidinzolghadr commented 7 years ago

I've read that php.ini needs to be in ALL folders that uses php, so I did copy my php.ini to all folders, even js one! Just to be sure! haha.

But same result. Maybe my php.ini file is not correct:

include_path = "/zirta/hib/htdocs/.linuxbrew/bin/youtube-dl" I've seen paths to have single dot in the beginning, so I'm not sure if I'm doing it right.

Kallys commented 7 years ago

You can try to add the following line in init.php line 10 : set_include_path(get_include_path() . PATH_SEPARATOR . '/zirta/hib/htdocs/.linuxbrew/bin');

Not tested and it's too late to go further for me. On next version of MediaDownloader, I've added a way to manually specify path to youtube-dl, but next version is not for soon...

aidinzolghadr commented 7 years ago

Sadly that did not work.

Thank you so much for all your time and effort, it's really appreciated.

Kallys commented 7 years ago

I'm not very familiar with restricted server environments but I tried to reproduce something similar and I made it working this way :

  1. I copied youtube-dl file to my web root (/var/www/html)
  2. chmod a+rx /var/www/html/youtube-dl
  3. I added this line in init.php line 10 : putenv('PATH=' . getenv('PATH') . PATH_SEPARATOR . '/var/www/html');

But maybe putenv() is restricted on your server (but normally PHP safe mode has been removed in PHP7).

The ultimate solution that will work for sure is to hardcode youtube-dl path. Replace every occurrence of "youtube-dl" by "/zirta/hib/htdocs/.linuxbrew/bin/youtube-dl" in code. GitHub may help you.

aidinzolghadr commented 7 years ago

Thanks.

First method didn't work, I went after the second one but there are more instances of youtube-dl that I had to change, strangely enough.

So I did that and it now shows file's properties and stuff but when I press download, it goes to download.php which is in root and throws an error:

Fatal error: Uncaught Error: Call to a member function load() on null in /MediaDownloader/download.php:8 Stack trace: #0 {main} thrown in /MediaDownloader/download.php on line 8

I think it means the $session is null.

Kallys commented 7 years ago

You're right, now fixed : 50c1730dcddf6e830717f0e03aa3649f35bd5d37 Thanks!

aidinzolghadr commented 7 years ago

Thanks, I just did your patch but now after I press download, it just loads the default screen. Same thing after going to the "Let me choose quality" and pressing download button.

Kallys commented 7 years ago

Sounds good ! Normally you should see "Background downloads" on 1/3 until download finish. Then your file should be listed in "Files" page (and available in your download directory).

aidinzolghadr commented 7 years ago

That's what I hoped for. There was no background download, even though I put a large youtube file to make sure it doesn't finish fast so I would not miss it. I checked the files section and it was empty.

aidinzolghadr commented 7 years ago

I also chacked permission for downloads/ and it was "drwx---r-x " so to make sure I changed it to 777, same results.

Kallys commented 7 years ago

Hum, strange. Have you tried the "Direct download" button ? Does it work ? Can I see your edited Downloader.php file ?

aidinzolghadr commented 7 years ago

I put a direct link to a zip file in the box and pressed direct download and it came up with this error:

Fatal error: Uncaught Error: Call to a member function GetStreamType() on null in /home/MediaDownloader/lib/Views/FormatSelection.php:88 Stack trace: #0 /home/MediaDownloader/download.php(68): MediaDownloader\Views\FormatSelection::PrintMediaFormatSelection(Object(MediaDownloader\MediaInfo), false, true) #1 {main} thrown in /home/MediaDownloader/lib/Views/FormatSelection.php on line 88

aidinzolghadr commented 7 years ago

And for my Downloader.php, here it is: http://pastebin.com/kEhqdi83

Kallys commented 7 years ago

Actually, "Download" means "Download to server (from hosting service)" and "Direct download" means "Download to client (from hosting service)". (That's the first reason why I forked to p1rox's because on his version you can only download from hosting service to server and then, download from server to client.)

So don't put a link to a zip file in the box, try with a youtube URL and then press the "Direct download" button.

Then, I checked your Downloader.php file, and there is still some occurences of "youtube-dl" that you didn't replace. Here is a the right one for your: https://framabin.org/?ffacb578702d2ac9#v6N90mDaPNMMv7JZnWyGAT+Pu0sZwgb36vdXG3GZQFY=

aidinzolghadr commented 7 years ago

Hey thanks it works! yay.

Is it possible to queue downloads? Like I have 10 links but I want it to download 3 files simultaneously, currently if you put how many links, it tries to download them all at once.

Kallys commented 7 years ago

Should be available in next version ! I'm working on it, but another project is currently taking all my time...

Since your problem is solved, I close this issue, but don't hesitate to open a new one if you find bugs or have suggestions. Thanks for your time and helping to improve MediaDownloader !