From 64a23b3dde5b8f505dd0d2db029494e8b19cb891 Mon Sep 17 00:00:00 2001 From: Ayberk Yilmaz Date: Sun, 13 Apr 2014 16:38:43 +0300 Subject: [PATCH 1/2] Added "feeling lucky" feature --- vlsub.lua | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 3f01926..a2693c1 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -111,6 +111,7 @@ local options = { " /!\\ Beware : Existing subtitles are overwrited without asking confirmation, so put them elsewhere if thet're important.
".. "
".. " Find more Vlc extensions at addons.videolan.org.", + int_feeling_lucky = 'I feel lucky', action_login = 'Logging in', action_logout = 'Logging out', @@ -352,6 +353,7 @@ function interface_main() dlg:add_label(lang["int_title"]..':', 1, 2, 1, 1) input_table['title'] = dlg:add_text_input(openSub.movie.title or "", 2, 2, 2, 1) dlg:add_button(lang["int_search_name"], searchIMBD, 4, 2, 1, 1) + dlg:add_button(lang["int_feeling_lucky"], feelingLucky, 4, 3, 1, 1) dlg:add_label(lang["int_season"]..':', 1, 3, 1, 1) input_table['seasonNumber'] = dlg:add_text_input(openSub.movie.seasonNumber or "", 2, 3, 2, 1) dlg:add_label(lang["int_episode"]..':', 1, 4, 1, 1) @@ -361,13 +363,34 @@ function interface_main() input_table['message'] = dlg:add_label(' ', 1, 6, 4, 1) dlg:add_button(lang["int_show_help"], show_help, 1, 7, 1, 1) dlg:add_button(' '..lang["int_show_conf"]..' ', show_conf, 2, 7, 1, 1) - dlg:add_button(lang["int_dowload_sel"], download_subtitles, 3, 7, 1, 1) + dlg:add_button(lang["int_dowload_sel"], download_index, 3, 7, 1, 1) dlg:add_button(lang["int_close"], deactivate, 4, 7, 1, 1) assoc_select_conf('language', 'language', openSub.conf.languages, 2, lang["int_all"]) display_subtitles() end +function configIMDB() + openSub.movie.title = trim(input_table["title"]:get_text()) + openSub.movie.seasonNumber = tonumber(input_table["seasonNumber"]:get_text()) + openSub.movie.episodeNumber = tonumber(input_table["episodeNumber"]:get_text()) + + local sel = input_table["language"]:get_value() + if sel == 0 then + openSub.movie.sublanguageid = 'all' + else + openSub.movie.sublanguageid = openSub.conf.languages[sel][1] + end +end + +function feelingLucky() + configIMDB() + openSub.checkSession() + openSub.request("SearchSubtitles") + download_subtitles(1) + deactivate() +end + function set_interface_main() -- Update movie title and co. if video input change if not type(input_table['title']) == 'userdata' then return false end @@ -1399,17 +1422,8 @@ function searchHash() end function searchIMBD() - openSub.movie.title = trim(input_table["title"]:get_text()) - openSub.movie.seasonNumber = tonumber(input_table["seasonNumber"]:get_text()) - openSub.movie.episodeNumber = tonumber(input_table["episodeNumber"]:get_text()) - local sel = input_table["language"]:get_value() - if sel == 0 then - openSub.movie.sublanguageid = 'all' - else - openSub.movie.sublanguageid = openSub.conf.languages[sel][1] - end - + configIMDB() if openSub.movie.title ~= "" then openSub.checkSession() openSub.request("SearchSubtitles") @@ -1443,9 +1457,13 @@ function get_first_sel(list) return 0 end -function download_subtitles() +function download_index(index) local index = get_first_sel(input_table["mainlist"]) - + + download_subtitles(index) +end + +function download_subtitles(index) if index == 0 then setMessage(lang["mess_no_selection"]) return false From 0a26379e40e3115226d978a2e050db97246a4870 Mon Sep 17 00:00:00 2001 From: Ayberk Yilmaz Date: Sun, 13 Apr 2014 17:24:02 +0300 Subject: [PATCH 2/2] Added empty movie title check to feeling lucky --- vlsub.lua | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index a2693c1..085fe7c 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -370,27 +370,6 @@ function interface_main() display_subtitles() end -function configIMDB() - openSub.movie.title = trim(input_table["title"]:get_text()) - openSub.movie.seasonNumber = tonumber(input_table["seasonNumber"]:get_text()) - openSub.movie.episodeNumber = tonumber(input_table["episodeNumber"]:get_text()) - - local sel = input_table["language"]:get_value() - if sel == 0 then - openSub.movie.sublanguageid = 'all' - else - openSub.movie.sublanguageid = openSub.conf.languages[sel][1] - end -end - -function feelingLucky() - configIMDB() - openSub.checkSession() - openSub.request("SearchSubtitles") - download_subtitles(1) - deactivate() -end - function set_interface_main() -- Update movie title and co. if video input change if not type(input_table['title']) == 'userdata' then return false end @@ -1422,8 +1401,24 @@ function searchHash() end function searchIMBD() - configIMDB() + makeImdbRequest() +end + +function configIMDB() + openSub.movie.title = trim(input_table["title"]:get_text()) + openSub.movie.seasonNumber = tonumber(input_table["seasonNumber"]:get_text()) + openSub.movie.episodeNumber = tonumber(input_table["episodeNumber"]:get_text()) + + local sel = input_table["language"]:get_value() + if sel == 0 then + openSub.movie.sublanguageid = 'all' + else + openSub.movie.sublanguageid = openSub.conf.languages[sel][1] + end +end + +function makeImdbRequest() if openSub.movie.title ~= "" then openSub.checkSession() openSub.request("SearchSubtitles") @@ -1431,6 +1426,13 @@ function searchIMBD() end end +function feelingLucky() + configIMDB() + makeImdbRequest() + download_subtitles(1) + deactivate() +end + function display_subtitles() local mainlist = input_table["mainlist"] mainlist:clear()