-1

I have written an mpv script in python using

https://github.com/iwalton3/python-mpv-jsonipc

I'm now trying to launch the script when mpv opens but cant seem to get it to launch I tried running from mpv with

mp.command("run", "python3", "D:\TingTingin\pycharmprojects\mpvipc\got launched.py")

and lua

os.execute("D:\TingTingin\pycharmprojects\mpvipc\got launched.py")

but the script doesn't run im not sure what im doing wrong

k-on fan
  • 101
  • 4
  • 1
    Backslashes must be escaped inside double-quoted string literals. – Egor Skriptunoff Jun 09 '21 at 18:04
  • 1
    thanks by using `mp.commandv("run", "python3", [[D:\TingTingin\pycharmprojects\mpvipc\got lanched.py]])` it seems to work need to put it inside [[]] also had to use commandv instead of command – k-on fan Jun 09 '21 at 18:51

2 Answers2

1

Backslashes must be escaped inside double-quoted string literals. Egor Skriptunoff

Using mp.commandv("run", "python3", [[D:\TingTingin\pycharmprojects\mpvipc\got launched.py]]) it seems to work need to put it inside [[]] also had to use commandv instead of command thanks to Egor Skriptunoff

k-on fan
  • 101
  • 4
0

I don't think scripts are automatically enabled, unless you specify during startup.

from mpv --list-options:

--script                         alias for --scripts-append (CLI/config files only)
--script-opts                    Key/value list (default: )
  --script-opts-add
  --script-opts-append
  --script-opts-set
  --script-opts-remove
--scripts                        String list (default: ) [file]
  --scripts-add
  --scripts-append
  --scripts-clr
  --scripts-del
  --scripts-pre
  --scripts-set
  --scripts-toggle
  --scripts-remove

Possibly use a GUI that allows you to permanently set startup-options that way, such as SMPlayer.

Be easy enough to alias your mpv command in .bash-aliases but I'm guessing you're on Windows because of the directory name...

alias mpv="mpv --script '/home/sketch2/Programming/Scripts/launched.py'"

a TSR that looks for launching, such as Devilspie2 would do it. Generally used for resizing and putting apps in locations you like. Something like that could be programmed to auto-run your mpv script. That might be Linux only, so you'd have to hunt for something similar in (assuming) Windows. Maybe it runs through their Linux-subsystem, I don't know. Doubt it, probably polls X in ways that windows wouldn't expect.

Are you gonna use it all the time, or just once in a while? Can you just have your script running in the background, and have it check for a running instance of mpv every 30 seconds or so? That's essentially what a TSR does.

https://github.com/mpv-player/mpv/wiki/User-Scripts


Edit:

I just realized there's an mpv.conf -- that's where you'd set it.
I don't know where it's stored on Windows, but on *nix it's in ~/.config/mpv/

Literally just commandline-parameters followed with what you set them to. Comments are #hashed out.

https://github.com/mpv-player/mpv/blob/master/etc/mpv.conf

Doyousketch2
  • 2,060
  • 1
  • 11
  • 11