Closed gbstan closed 4 years ago
Here are some links that might help for this: https://github.com/mpv-player/mpv/issues/4653#issuecomment-317411382 https://github.com/rossy/mpv-repl/blob/master/repl.lua#L507-L546
@gbstan Thanks for sharing the links. It sure is helpful.
However, currently I do not own mac to test adding compatibility.
Perhaps in future.
@gbstan I have added initial compatibility for supporting multiple platforms in SmartCopyPaste 1.9. MAC OS X requires pbpaste, Linux requires xclip
Currently only pasting should work in MAC OS X and Linux, copying for both platforms is still not supported. Once I support copying I will notify you ^ ^
I have attached the script, please do let me know if pasting works so I add it as an offical release. SmartCopyPaste-1.9.lua.zip
Side note: SmartCopyPaste-II wont feature multiple platforms until I find a method for the way I am creating logfiles (will probably take ages due to my lazyness and the fact that I dont have MAC OS X).
Thank you! On MacOS and Linux, I would use/create the log files within ~/.config/mpv (i.e. one directory above where the script itself is stored). This is also where history.log for mpv is located. I guess the content and writing of information in the file mpvClipboard.log is the same for all platforms.
You are welcome!
Guess it means it worked for you, however for mpvClipboard.log, (the II version), I'll see what can be done in the future.
When I have free time I'll first focus in enhancing the initial support and getting the copy feature to work.
Issue is closed since initial support is done.
Unfortunately the paste (ctrl+v) didn't work. Here is the error message
[SmartCopyPaste_1_9]
[SmartCopyPaste_1_9] stack traceback:
[SmartCopyPaste_1_9] ...-bartstan/.config/mpv/scripts/SmartCopyPaste-1.9.lua:30: in function <...-bartstan/.config/mpv/scripts/SmartCopyPaste-1.9.lua:25>
[SmartCopyPaste_1_9] (tail call): ?
[SmartCopyPaste_1_9] ...-bartstan/.config/mpv/scripts/SmartCopyPaste-1.9.lua:159: in function 'fn'
[SmartCopyPaste_1_9] mp.defaults:202: in function 'fn'
[SmartCopyPaste_1_9] mp.defaults:60: in function 'handler'
[SmartCopyPaste_1_9] mp.defaults:339: in function 'handler'
[SmartCopyPaste_1_9] mp.defaults:460: in function 'call_event_handlers'
[SmartCopyPaste_1_9] mp.defaults:494: in function 'dispatch_events'
[SmartCopyPaste_1_9] mp.defaults:453: in function <mp.defaults:452>
[SmartCopyPaste_1_9] [C]: ?
[SmartCopyPaste_1_9] [C]: ?
[SmartCopyPaste_1_9] Lua error: ...-bartstan/.config/mpv/scripts/SmartCopyPaste-1.9.lua:30: attempt to call global 'paste' (a nil value)
Hmm, can you try this SmartCopyPaste-1.91.lua.zip
If it did not work, try typing 'macos' instead of nil inside the script and let me know. so it will be local platform = 'macos'
Just tried it. It seems the script identifies linux instead of macOS when I press ctrl+v
[SmartCopyPaste_1_91] There was an error getting linux clipboard:
[SmartCopyPaste_1_91] Status: -1
[SmartCopyPaste_1_91] Error: init
[SmartCopyPaste_1_91] stdout:
[SmartCopyPaste_1_91] args: {"xclip", "-selection", "primary", "-out"}
AV: 00:00:05 / 00:01:11 (7%) A-V: 0.000 Dropped: 4
[SmartCopyPaste_1_91] There was an error getting linux clipboard:
[SmartCopyPaste_1_91] Status: -1
[SmartCopyPaste_1_91] Error: init
[SmartCopyPaste_1_91] stdout:
[SmartCopyPaste_1_91] args: {"xclip", "-selection", "primary", "-out"}
Seems that the detect platform I forked is not working properly, you can manually select the platform. Open the script with any text editor, replace local platform = nil With local platform = 'macos'
Let me know what happens
Yes, this works if I press ctrl+v (tried with a youtube URL) and then Enter. It does not work without pressing Enter after ctrl+v
Are you pasting in mpv gui or the terminal? Can you provide me with a screenshot so I see what is happening?
It actually works without pressing enter. It just takes ~2 seconds to start playing the video, which I probably didn't realise until now.
Glad to see it finally working.
I still don't understand the cause for the delay, this could have to do with pbpaste. Or sometimes scripts just don't function properly and experience slow-downs for some reason.
The delay might get fixed by itself. However, I'll try to enhance the cross-platform support further in the near future.
Might be due to the time it takes to load the video from youtube? I have not tried yet with a local link.
Does the message of pasting show quickly? YouTube generally will have delay because it needs to find the actual video link from the pasted YouTube URL
Yes, the message of pasting is immediate.
Seems like initial support is done, will close the issue for now and improve the support gradually.
@gbstan I have made an update, it should automatically know you are using MAC OS X. Also, it should be able to copy now and paste.
Let me know if the above works for you without problems :) https://github.com/Eisa01/mpv-scripts/blob/master/scripts/SmartCopyPaste-1.93.lua
If things work, I think I might proceed and support my other scripts to work for MAC OS X and Linux.
Yes, this seems to work now.
Thanks for testing. I have updated all of my scripts. All scripts now support MAC OS and Linux.
You can use now SmartHistory and SmartCopyPaste-II also.
Thank you so much! Very appreciated and very useful scripts
@Eisa01 I'm on linux, but the auto-detection thinks I'm on osx. os.execute
returns a number (the exit code) not nil or true for whatever version of lua mpv uses, so the osx check always succeeds even though I don't have either of those directories. Is this not the case for you?
@noctuid Can you let me know which flavor of linux you are using so I check?
Arch, but I don't think it should matter. Does os.execute
behave differently for you?
@noctuid Tested on Ubuntu the check for directory fails and it successfully detects Linux. I will need to see what ur returns in order to handle the detection issue.
In Ubuntu, if you run luajit
and then print(os.execute("false"))
do you get nil
? I get a number. Lua 5.3 returns nil
, but only 5.1 and 5.2 are supported by mpv.
Okay, it looks like this is actually a difference between 5.1 and 5.2. 5.1 returns a non-zero number and 5.2 returns nil on failure. Could you make the check to see if the result is 0
or true
instead of whether the result is truthy?
@noctuid I have made the check as you have mentioned above, so that it checks for 0 and true. Can you test and let me know if this fixed auto detection for you? SmartCopyPaste-II-2.1#2.txt Rename it to .lua
@gbstan I have also made it so the MAC uses command button instead of ctrl,I just found out that everything there uses command instead of ctrl for some reason.
That works, but I think it should be something like (unsimplified) os.execute '[ -d "/Applications" ]' == 0 and os.execute '[ -d "/Library" ]' == 0 or os.execute '[ -d "/Applications" ]' == true and os.execute '[ -d "/Library" ]' == true
otherwise the check for /Applications
doesn't have any effect on lua 5.1.
@noctuid Thanks, it makes sense. Will modify it as you have mentioned and will release it tomorrow in 2.1. ^ ^
Good script. Would be really cool to get SmartCopyPaste to also work on MacOS X. Access to the clipboard on MacOS X from the command line can be done with pbcopy and pbpaste. This should allow you to adapt your script for MacOS X too.