woodruffw / ff2mpv

A Firefox/Chrome add-on for playing URLs in mpv.
https://addons.mozilla.org/en-US/firefox/addon/ff2mpv/
Other
521 stars 52 forks source link

yt-dlp from pip doesn't work #88

Closed fromtheeast710 closed 2 years ago

fromtheeast710 commented 2 years ago

Describe the bug

If yt-dlp is installed via pip, FF2MPV would not play any video. MPV still plays video if used from the terminal.

Reproduction steps

Steps to reproduce the behavior:

  1. Remove the yt-dlp package by your package-manager
  2. Execute pip install yt-dlp
  3. Try to play video with FF2MPV
  4. No video is played

Platform information

Additional context (optional)

I tried making a symlink from ~/.local/bin/yt-dlp to /usr/bin but it still wouldn't work.

woodruffw commented 2 years ago

That's strange -- I currently use yt-dlp with ff2mpv without problems (on Ubuntu 22.04, I'll check the MPV version when I'm in front of that computer again).

In general, ff2mpv is completely agnostic to yt-dlp or youtube-dl -- it only executes MPV, which in turn is responsible for executing either yt-dlp or youtube-dl. The fact that it's failing in the browser but succeeding on the terminal suggests a $PATH discrepancy; what's your $PATH?

fromtheeast710 commented 2 years ago

echo $PATH shows me /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/theeast/.local/bin:/home/theeast/.local/bin

woodruffw commented 2 years ago

Gotcha. Is your MPV configured to use yt-dlp instead of youtube-dl?

It should be something like this (in your MPV config):

script-opts=ytdl_hook-ytdl_path=yt-dlp
fromtheeast710 commented 2 years ago

Yes there is. As I've said MPV works totally fine when execute from the terminal.

woodruffw commented 2 years ago

Okay. Just to confirm, was ff2mpv previously working for you and is now broken? Or are you attempting to configure it for the first time and not seeing anything happen when you use it?

fromtheeast710 commented 2 years ago

ff2mpv was working with the yt-dlp installed by pacman but failed if it was installed by pip. I didn't configure anything.

woodruffw commented 2 years ago

Hmm. The only other thing I can think of, then, is that the pip user-local binary path isn't on the default $PATH for your noninteractive programs. That can happen because ff2mpv doesn't go through a shell to spawn mpv, meaning that mpv inherits its $PATH from whatever browser helper spawns the native client (which in turn inherits it from the WM/DE's environment).

I don't know what your local setup looks like, but in general the "right" way to do that is to ensure that the $PATH is fully configured in whatever initfile or WM-specific initialization file spawns your X11 WM or DE.

Alternatively, you could patch the native client in a manner similar to what we do for macOS:

https://github.com/woodruffw/ff2mpv/blob/1f6cfc480270ef2c8eae81a37d470251b5d2cf31/ff2mpv.py#L22-L31

I'd be receptive to a PR that does that as well, since this is probably a common error case.

fromtheeast710 commented 2 years ago

Yup, with pip, everything is installed in ~/.local/bin but that path is already included in my $PATH via export PATH="$PATH:/home/theeast/.local/bin". Also weird that a symlink wouldn't work.

Your patch did work though.

woodruffw commented 2 years ago

Yup, with pip, everything is installed in ~/.local/bin but that path is already included in my $PATH via export PATH="$PATH:/home/theeast/.local/bin". Also weird that a symlink wouldn't work.

Yeah, that's very strange. Maybe the symlink didn't carry the executable bit? I don't remember the semantics for that, off the top of my head.

This is one of my least favorite things about the Linux desktop environment: any PATH initialization you do in your shell profile(s) has absolutely nothing to do with your DE/WM environment, unless the latter happens to be initialized via the former. Mine is but many peoples' aren't, leading to hard-to-debug problems like this.

Your patch did work though.

Glad to hear it. I'll make that an "official" part of the client the next time someone has trouble with this.