Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added feeling lucky button #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions vlsub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ local options = {
int_help = 'Help',
int_search_hash = 'Search by hash',
int_search_name = 'Search by name',
int_feeling_lucky = 'I\'m feeling lucky',
int_title = 'Title',
int_season = 'Season (series)',
int_episode = 'Episode (series)',
Expand Down Expand Up @@ -386,7 +387,7 @@ function input_changed()
end

--[[ Interface data ]]--

function interface_main()
dlg:add_label(lang["int_default_lang"]..':', 1, 1, 1, 1)
input_table['language'] = dlg:add_dropdown(2, 1, 2, 1)
Expand All @@ -398,6 +399,9 @@ function interface_main()
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)
Expand All @@ -412,7 +416,7 @@ function interface_main()
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)
lang["int_dowload_sel"], download_subtitle, 3, 7, 1, 1)
dlg:add_button(
lang["int_close"], deactivate, 4, 7, 1, 1)

Expand Down Expand Up @@ -1625,6 +1629,11 @@ function searchIMBD()
end
end

function feelingLucky()
searchHash()
download_subtitle(1)
end

function display_subtitles()
local mainlist = input_table["mainlist"]
mainlist:clear()
Expand Down Expand Up @@ -1653,8 +1662,10 @@ function get_first_sel(list)
return 0
end

function download_subtitles()
local index = get_first_sel(input_table["mainlist"])
function download_subtitle(index)
if not index then
index = get_first_sel(input_table["mainlist"])
end

if index == 0 then
setMessage(lang["mess_no_selection"])
Expand Down