woodruffw / ff2mpv

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

MPV fails to play stream torrent files or magnet links when launched from ff2mpv #123

Closed soredake closed 2 months ago

soredake commented 2 months ago

IMPORTANT: Do not file reports about specific sites breaking when others continue to work. This indicates an upstream error that ff2mpv cannot fix and must be raised upstream instead.

IMPORTANT: Please check the Common problems page for debugging tips before submitting an issue. Duplicates of any information on that page will be closed.

IMPORTANT: Please fill out every section below. Bug reports with missing information will be given a lower priority or closed outright.

Describe the bug

A clear and concise description of what the bug is.

Reproduction steps

Steps to reproduce the behavior:

  1. Install addon + mpv + webtorrent-mpv-hook on Windows
  2. Press "Open in MPV" on .torrent url or magnet (I used nyaa torrent)
  3. In case of the .torrent url, mpv starts and after a couple of second it closes.
  4. With magnet links, mpv does not even opens.

Expected behavior

.torrent links and magnets should work in mpv, they do when i do mpv <torrent link> and mpv "<magnet>" in powershell.

Screenshots (optional)

If applicable, add screenshots to help explain your problem.

Platform information

Additional context (optional)

Add any other context about the problem here.

woodruffw commented 2 months ago

Thanks for your report. Do other URLs work for you? ff2mpv is a very thin wrapper over mpv, so any failure to play a specific kind of media here almost certainly indicates either a problem with how mpv is invoking the hook or something about the URL being malformed.

soredake commented 2 months ago

Do other URLs work for you?

Yes, playing youtube links works fine.

soredake commented 2 months ago

I see this command line in process explorer before mpv closes: image

Using this same command line in pwsh I see torrent loaded in mpv: mpv --no-terminal -- https://nyaa.si/download/1812051.torrent

woodruffw commented 2 months ago

Gotcha, that looks right. The only other thing I can think of is a $PATH issue, but I don't know much about how MPV hooks work.

The basic version is that, in ff2mpv, your browser executes the mpv subprocess with whatever $PATH it pleases, which on some hosts doesn't necessarily contain paths needed for things like helper scripts. If your MPV hook relies on a helper tool or script being somewhere on a customized $PATH, then it's possible MPV is failing within ff2mpv because the browser isn't using your $PATH.

For an example of this kind of hack (for macOS in this example), see:

https://github.com/woodruffw/ff2mpv/blob/4585f178bbb40414bfc7ba8689d4575853bca2e2/ff2mpv#L14-L21

soredake commented 2 months ago

I figured out why it's not working, sorry! It's such a silly mistake, while setting up ff2mpv i removed nodejs and installed nodejs-lts, and forgot to restart the browser, so PATH still had path to nodejs binary, which is no longer installed.

woodruffw commented 2 months ago

No problem, glad you were able to resolve it. I appreciate you filling out the entire issue in full detail, and posting your resolution!