mrxdst/webtorrent-mpv-hook

Work with scripts that allow pasting into the playlist

Closed this issue · 4 comments

There are several plugins that allow pasting a path/url into the playlist (e.g. this one). Pasting a torrent identifier into the playlist does not seem to normally work with this plugin (on loading, it ends up being removed from the playlist). My scripts support this functionality (on load they will check if the filename is a torrent and run btfs or webtorrent). I often find it nicer to just hit one key instead of restarting mpv.

This hook was never designed to be used as part of a playlist.
The on_load hook in mpv only expects one stream, so in order do be able to open multi-file torrents it "reopens" a new playlist instead.
It's probably possible to solve but it would cause a lot of other problems as multiple torrents could be active at the same time, complicating the hook far beyond my use case.

FYI. I just have magnet links associated with mpv. So clicking any magnet-link just opens up a new mpv instance.

FYI. I just have magnet links associated with mpv. So clicking any magnet-link just opens up a new mpv instance.

I have different settings/working directories for different mpv instances where some extra setup is required, so I can't use this solution.

Okay, I see that the issue is not that pasting into the playlist doesn't work but that it doesn't work if there is already a webtorrent instance. The way I'm handling it is to just set stream-open-filename in the on_load hook to the directory the files are being downloaded to, and mpv automatically handles adding the files to the playlist. You can't really do the same thing if you're adding the http://localhost urls for webtorrent to the playlist.

I think it makes sense to not support this if handling multiple webtorrent instances is complicated.

By the way, is there a reason on_load_fail is used instead of on_load?

Well. Since it allows opening torrents on just info-hash. A local file could potentially be mistaken for a torrent info-hash. But it's probably pretty rare.

It could be changed so it uses both hooks. on_load for magnet links and torrent files, and on_load_fail for info hash. But I don't think it's an actual issue as it is.