arieleg / mpv-copytime Goto Github PK
View Code? Open in Web Editor NEWCopy the current time of the video to clipboard.
License: GNU General Public License v3.0
Copy the current time of the video to clipboard.
License: GNU General Public License v3.0
I use wl-copy with Sway and xclip with i3 under Arch Linux. I generally prefer using Sway, but I can't use it all the time because certain applications only work properly on i3.
Under Sway, when mpv is run as a native Wayland application, pressing the key combination defined in mp.add_key_binding
at the end of the script doesn't actually copy the current time to the clipboard; it only shows the OSD message, 'Copied to Clipboard: [timecode]'
My knowledge in Lua is rather limited, but by looking at the script, I've been able to find that it only checks whether each supported clipboard manager exists in an if-else statement. In my case, xclip
is available (the first part of the if statement) and so xclip -silent -in -selection clipboard
is run, but it doesn't work under Wayland.
I wonder how to solve this. One idea is to check the current value of the environment variable $XDG_SESSION_TYPE
. If it is wayland
, use wl-copy
, and if it is x11
, use xclip
.
Hi, it works great on my Mac, amazing! Just wondering if it is possible to bind the Command key, say, Cmd + C, instead of Ctrl + C?
Hello, please help me remove milliseconds from the script. I don't need them in my work, but they take time to delete.
Hey, launching PowerShell with the -NoProfile
argument makes it launch faster since it does not have to look for a profile / load one if it finds one
You could also check if pwsh.exe
is found in path, and use it if it exists for an even faster startup
I would have made a PR but I don't know anything about lua
Hi, this is a really helpful script, thank you so so so much for sharing this! Just two questions, maybe you could help some:
How to add something like space in the final text, like: "The time is HH:MM:SS." ? I tried to edit the js script, it works but no spaces are generated, not sure why. I mean, my result keep being "ThetimeisHH:MM:SS.".
When it's working, I don't know why but I have to wait for about 2~3 secs until the new copied text finally replace the previous one. I mean, how to speed up the process a bit?
Thanks again for these great scripts!
I try to do follow the instructions but i don't get any result. The command [Ctrl + Alt + C] it's not functional in my operating system.
I install PowerShell on Linux.
Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
Unable to Use input function in Python (Spyder)
Found that the hotkey binding does not work on my Win 10 system unless I add Ctrl+c script-binding copyTime
to %AppData%\mpv\input.conf
.
I know the script loads the functions because of the trace message I added at the bottom, and that the function also works because using tilde (~
) I can execute the function explicitly using the console and this command: script-message copyTime
.
I had installed mpv.net which seems to have added entries to that file, so I downloaded a fresh copy from https://github.com/mpv-player/mpv/raw/master/etc/input.conf.
I tried other hotkeys such as c
, C
, and Ctrl+C
by duplicating the script's hotkey line at the end, but none of them work..
I do not have programs such as AutoHotKey running at the moment. I do have the PowerToys normal and Awake programs running, but should not interfere. I even tested with that component disabled, and encountered the same, negative result.
Don't think Steam interferes either, as it only provides desktop input configuration for controllers.
Otherwise this script works on my other machines with other OSs, and another Windows one, and I thought even this one before, where I've only installed controller drivers and AHK, so not sure what would break it..
I tried updating to mpv-x86_64-20220619-git-c1a46ec
from https://sourceforge.net/projects/mpv-player-windows/files/ and my old version 0.33 I think, but thta did not help either.
mp.add_key_binding("Ctrl+C", "copyTime", copyTime)
mp.add_key_binding("Ctrl+c", "copyTime", copyTime)
mp.add_key_binding("c", "copyTime", copyTime)
mp.add_key_binding("C", "copyTime", copyTime)
mp.osd_message("script end copyTime")
> mpv --input-test --force-window --idle
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
[copyTime] No supported clipboard command found
[input] Key c is bound to:
[input] (nothing)
[input] Key C is bound to:
[input] 1. 'script-binding copyTime/copyTime' in section {input_copyTime} in <api>:1 (default)
[input] Key Ctrl+c is bound to:
[input] 1. 'quit 4' in <builtin>:1 (default)
[input] Key Ctrl+C is bound to:
[input] (nothing)
The program stays open when I press that combination, as you can see continued message output.
Now seeing in my %AppData%\mpv\mpv.conf
, commenting a line to #input-default-bindings = no
improved my bindings in general, made Ctrl+c
quit the program, and now only C
works to copy the time..
Adding Ctrl+c ignore
to input.conf
at least stops the quit functionality..
When the second counter in video is between 30 and 60, the "copied to clipboard" time value displayed on the screen is incorrectly incremented to the next minute. The problem is demonstrated in this video: https://youtu.be/TDMy5ifh1d8
In the video, I repetitively press ctrl-C. As you can see, the "copied to clipboard" value is correct up to 29 seconds. After 29 seconds the "copied to clipboard" is one minute greater than it should be.
It looks like the divmod function needs a math.floor() around the "a/b".
local function divmod(a, b)
return math.floor(a / b), a % b
end
Thanks for the useful code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.