[vlc-devel] [PATCH 2/2] VLSub: add a feature "Action on start" that allows to search & download subtitles automatically by hash after VLSub is opened.
Adrian Borkiet
adrian.borkiet at gmail.com
Thu Aug 30 16:37:39 CEST 2018
---
share/lua/extensions/VLSub.lua | 53 ++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index 720dd08cdc..482755ead8 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
local options = {
language = nil,
downloadBehaviour = 'save',
+ actionOnStart = 'none',
langExt = false,
removeTag = false,
showMediaInformation = true,
@@ -72,6 +73,7 @@ local options = {
int_show_help = 'Show help',
int_show_conf = 'Show config',
int_dowload_sel = 'Download selection',
+ int_action_on_start = 'Action on start',
int_close = 'Close',
int_ok = 'Ok',
int_save = 'Save',
@@ -89,6 +91,8 @@ local options = {
int_display_code = 'Display language code in file name',
int_remove_tag = 'Remove tags',
int_vlsub_work_dir = 'VLSub working directory',
+ int_none = 'None',
+ int_search_hash_and_download = 'Search by hash, download and apply',
int_os_username = 'Username',
int_os_password = 'Password',
int_help_mess =[[
@@ -329,11 +333,11 @@ local select_conf = {} -- Drop down widget / option table association
function descriptor()
return {
- title = "VLsub 0.11.1",
- version = "0.11.1",
+ title = "VLsub 0.11.2",
+ version = "0.11.2",
author = "exebetche",
url = 'http://www.opensubtitles.org/',
- shortdesc = "VLsub";
+ shortdesc = "&VLsub";
description = options.translation.int_descr,
capabilities = {"menu", "input-listener" }
}
@@ -353,6 +357,14 @@ function activate()
end
show_main()
+ if openSub.option.actionOnStart == 'search' or openSub.option.actionOnStart == 'search-download' then
+ searchHash()
+ end
+ if openSub.option.actionOnStart == 'search-download' then
+ download_subtitles(1)
+ end
+
+
end
function close()
@@ -463,27 +475,30 @@ function interface_config()
dlg:add_label(
lang["int_remove_tag"]..':', 1, 5, 0, 1)
input_table['removeTag'] = dlg:add_dropdown(3, 5, 1, 1)
+ dlg:add_label(
+ lang["int_action_on_start"]..':', 1, 6, 0, 1)
+ input_table['actionOnStart'] = dlg:add_dropdown(3, 6, 1, 1)
dlg:add_label(
- lang["int_os_username"]..':', 1, 7, 0, 1)
+ lang["int_os_username"]..':', 1, 8, 0, 1)
input_table['os_username'] = dlg:add_text_input(
type(openSub.option.os_username) == "string"
- and openSub.option.os_username or "", 2, 7, 2, 1)
+ and openSub.option.os_username or "", 2, 8, 2, 1)
dlg:add_label(
- lang["int_os_password"]..':', 1, 8, 0, 1)
+ lang["int_os_password"]..':', 1, 9, 0, 1)
input_table['os_password'] = dlg:add_password(
type(openSub.option.os_password) == "string"
- and openSub.option.os_password or "", 2, 8, 2, 1)
+ and openSub.option.os_password or "", 2, 9, 2, 1)
input_table['message'] = nil
- input_table['message'] = dlg:add_label(' ', 1, 9, 3, 1)
+ input_table['message'] = dlg:add_label(' ', 1, 10, 3, 1)
dlg:add_button(
lang["int_cancel"],
- show_main, 2, 10, 1, 1)
+ show_main, 2, 11, 1, 1)
dlg:add_button(
lang["int_save"],
- apply_config, 3, 10, 1, 1)
+ apply_config, 3, 11, 1, 1)
input_table['langExt']:add_value(
lang["int_bool_"..tostring(openSub.option.langExt)], 1)
@@ -494,6 +509,12 @@ function interface_config()
input_table['removeTag']:add_value(
lang["int_bool_"..tostring(not openSub.option.removeTag)], 2)
+ assoc_select_conf(
+ 'actionOnStart',
+ 'actionOnStart',
+ openSub.conf.actionOnStart,
+ 1)
+
assoc_select_conf(
'intLang',
'intLang',
@@ -915,6 +936,11 @@ function SetDownloadBehaviours()
{'save', lang["int_dowload_save"]},
{'manual', lang["int_dowload_manual"]}
}
+ openSub.conf.actionOnStart = {
+ {'none', lang["int_none"]},
+ {'search', lang["int_search_hash"]},
+ {'search-download', lang["int_search_hash_and_download"]}
+ }
end
function get_available_translations()
@@ -1013,6 +1039,7 @@ openSub = {
useragent = "VLSub 0.11.1",
translations_avail = {},
downloadBehaviours = nil,
+ actionOnStart = nil,
languages = languages
},
option = options,
@@ -1457,8 +1484,10 @@ function find_subtitle_in_archive(archivePath, subfileExt, subFileName)
return nil
end
-function download_subtitles()
- local index = get_first_sel(input_table["mainlist"])
+function download_subtitles(index)
+ if not index then
+ index = get_first_sel(input_table["mainlist"])
+ end
if index == 0 then
setMessage(lang["mess_no_selection"])
--
2.17.1
More information about the vlc-devel
mailing list