Advertisement
Guest User

Now Playing Text plugin for VLC

a guest
Feb 22nd, 2013
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. -- Extension description
  2. function descriptor()
  3.  return { title = "Now Playing Text File" ;
  4.   version = "1.0" ;
  5.   author = "TheFuzzy" ;
  6.   shortdesc = "Outputs song to text file";
  7.   description = "Outputs the title of the currently playing song to a text file." ;
  8.   capabilities = { "input-listener" }
  9.  }
  10. end
  11. pathdialog=0
  12. function activate()
  13.    vlc.msg.dbg("[now playing text] Welcome")
  14.    --vlc.msg.dbg("[now playing text] Files will be stored in")
  15.    --vlc.msg.dbg(vlc.config.userdatadir())
  16.  
  17.    titlefile=vlc.config.userdatadir().."/np_title.txt"
  18.    artistfile=vlc.config.userdatadir().."/np_artist.txt"
  19.    -- ensure files are created
  20.    pcall(dofile,titlefile)
  21.    pcall(dofile,artistfile)
  22.    pathdialog = vlc.dialog( "Now Playing Text" )
  23.    pathdialog:add_label( "Your text files will be located here:" )
  24.    pathdialog:add_text_input( vlc.config.userdatadir(), 1, 3, 4, 1)
  25.    pathdialog:add_button( "_Ok", hide_dialog )
  26.    
  27.    local input = vlc.object.input()
  28.    if input then input_changed() end
  29. end
  30. function meta_changed()
  31. end
  32. function deactivate()
  33.  vlc.msg.dbg("[now playing text] deact")
  34.  pathdialog:delete()
  35. end
  36.  
  37. function save_title()
  38. -- save title
  39.  local item=vlc.item or vlc.input.item()
  40.  io.output(titlefile)
  41.  io.write(item:metas()["title"])
  42.  io.close()
  43. end
  44. function save_artist()
  45. -- save artist
  46.  local item=vlc.item or vlc.input.item()
  47.  io.output(artistfile)
  48.  io.write(item:metas()["artist"])
  49.  io.close()
  50. end
  51.  
  52.  
  53. function input_changed()
  54.  vlc.msg.dbg("[now playing text] input changed..!")
  55.  local item=vlc.item or vlc.input.item()
  56.  if item then
  57.   save_title()
  58.   save_artist()
  59.  end
  60.  return false
  61. end
  62.  
  63. function hide_dialog()
  64.  pathdialog:hide()
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement