Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Extension description
- function descriptor()
- return { title = "Now Playing Text File" ;
- version = "1.0" ;
- author = "TheFuzzy" ;
- shortdesc = "Outputs song to text file";
- description = "Outputs the title of the currently playing song to a text file." ;
- capabilities = { "input-listener" }
- }
- end
- pathdialog=0
- function activate()
- vlc.msg.dbg("[now playing text] Welcome")
- --vlc.msg.dbg("[now playing text] Files will be stored in")
- --vlc.msg.dbg(vlc.config.userdatadir())
- titlefile=vlc.config.userdatadir().."/np_title.txt"
- artistfile=vlc.config.userdatadir().."/np_artist.txt"
- -- ensure files are created
- pcall(dofile,titlefile)
- pcall(dofile,artistfile)
- pathdialog = vlc.dialog( "Now Playing Text" )
- pathdialog:add_label( "Your text files will be located here:" )
- pathdialog:add_text_input( vlc.config.userdatadir(), 1, 3, 4, 1)
- pathdialog:add_button( "_Ok", hide_dialog )
- local input = vlc.object.input()
- if input then input_changed() end
- end
- function meta_changed()
- end
- function deactivate()
- vlc.msg.dbg("[now playing text] deact")
- pathdialog:delete()
- end
- function save_title()
- -- save title
- local item=vlc.item or vlc.input.item()
- io.output(titlefile)
- io.write(item:metas()["title"])
- io.close()
- end
- function save_artist()
- -- save artist
- local item=vlc.item or vlc.input.item()
- io.output(artistfile)
- io.write(item:metas()["artist"])
- io.close()
- end
- function input_changed()
- vlc.msg.dbg("[now playing text] input changed..!")
- local item=vlc.item or vlc.input.item()
- if item then
- save_title()
- save_artist()
- end
- return false
- end
- function hide_dialog()
- pathdialog:hide()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement