Baldomo / open-in-mpv

Simple web extension to open videos in mpv
GNU General Public License v3.0
110 stars 6 forks source link

feature: Specify working directory #31

Closed Tremolo4 closed 2 weeks ago

Tremolo4 commented 1 month ago

Feature Description

I'd like to be able to specify the working directory that the player executable is executed in.

Currently, on windows, open-in-mpv starts players in C:\Windows\system32.

Additional Context (optional)

For some reason mpv/yt-dlp fails to play some, but not all, youtube videos if it is started from a non-writable directory. *

It would be cool if open-in-mpv could by default start players from the users home directory instead of C:\Windows\system32. Or at least have an option to specify the working directory.

For now, I'm using the batch script below as the players.mpv.executable. This fixes my issue.

* Took me ages to figure this out. I think it's maybe trying to write a temporary file to the working directory, which it then deletes immediately. I can see something appear briefly by starting mpv in an empty folder and then hammering F5 in explorer lol.

Code Snippet (optional)

cd %UserProfile%

start "" mpv.exe %*

Checklist:

Baldomo commented 1 month ago

I understand your request, but I must ask why would you need such functionality? I'm unsure about the usefulness of such a feature for the following reasons:

Tremolo4 commented 3 weeks ago

Thanks for the response and thanks for this tool in general, love it!

why would you need such functionality?

Just to reiterate what I've tried to describe in my first post: For some youtube videos, yt-dlp fails/hangs silently if it can't write to the working directory.

However, I have since found that specifying a temp directory for yt-dlp like so --paths temp:%TMP% fixes the problem as well.

Baldomo commented 2 weeks ago

I'm glad you found a solution that's working for you, I'll probably add this tip to the README under a "troubleshooting" section of some sorts. Just to double down on my point, I don't think running executables in the user's home dir by default would be wise, as a malicious actor could sneak a fake player with an associated malicious configuration and get access to the user's home or other directories