Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2018
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. local mp = require 'mp'
  2. local clipboard = require 'utilities.clipboard'
  3.  
  4. function load_file_from_clipboard()
  5.     local content = clipboard.get_clipboard(true)
  6.    
  7.     if content and content ~= '' and content ~= 'error' then
  8.         mp.osd_message('Opening file: ' .. content)
  9.         mp.commandv('loadfile', content, 'replace')
  10.     elseif(content == 'error') then
  11.         mp.osd_message('Error getting clipboard contents!')
  12.     else
  13.         mp.osd_message('Clipboard is empty, or not a string')
  14.     end
  15. end
  16.  
  17. function append_file_from_clipboard()
  18.     local content = clipboard.get_clipboard(true)
  19.    
  20.     if content and content ~= '' and content ~= 'error' then
  21.         mp.osd_message('Appending file: ' .. content)
  22.         mp.commandv('loadfile', content, 'append-play')
  23.     elseif(content == 'error') then
  24.         mp.osd_message('Error getting clipboard contents!')
  25.     else
  26.         mp.osd_message('Clipboard is empty, or not a string')
  27.     end
  28. end
  29.  
  30. function copy_file_path_to_clipboard()
  31.     local filename = mp.get_property('path')
  32.     if filename then
  33.         mp.osd_message('Filename copied to clipboard: ' .. filename)
  34.         clipboard.set_clipboard(filename)
  35.     else
  36.         mp.osd_message('No file')
  37.     end
  38. end
  39.  
  40. mp.register_script_message('load_file_from_clipboard', load_file_from_clipboard)
  41. mp.register_script_message('append_file_from_clipboard', append_file_from_clipboard)
  42. mp.register_script_message('copy_file_path_to_clipboard', copy_file_path_to_clipboard)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement