From 5f0c9b17afc566643be970d940703caf97639b73 Mon Sep 17 00:00:00 2001 From: Juuso Date: Wed, 26 Nov 2014 16:03:11 +0200 Subject: [PATCH 1/9] Added keyboard shortcuts for pull-down menu item and most used buttons (search, download, close) Download button downloads first in search list if user didnt select any Automatic search on first load Plugin window closes now straight after download --- vlsub.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 33bdfea..294a2bb 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -64,15 +64,15 @@ local options = { int_config = 'Config', int_configuration = 'Configuration', int_help = 'Help', - int_search_hash = 'Search by hash', + int_search_hash = '&Search by hash', int_search_name = 'Search by name', int_title = 'Title', int_season = 'Season (series)', int_episode = 'Episode (series)', int_show_help = 'Show help', int_show_conf = 'Show config', - int_dowload_sel = 'Download selection', - int_close = 'Close', + int_dowload_sel = '&Download selection', + int_close = '&Close', int_ok = 'Ok', int_save = 'Save', int_cancel = 'Cancel', @@ -326,7 +326,7 @@ local select_conf = {} -- Drop down widget / option table association function descriptor() return { - title = "VLsub 0.9.13", + title = "&VLsub 0.9.13", version = "0.9.13", author = "exebetche", url = 'http://www.opensubtitles.org/', @@ -553,6 +553,8 @@ function trigger_menu(dlg_id) dlg = vlc.dialog( openSub.conf.useragent) interface_main() + -- Trigger search after window has appeared + searchHash() elseif dlg_id == 2 then close_dlg() dlg = vlc.dialog( @@ -1656,17 +1658,22 @@ end function download_subtitles() local index = get_first_sel(input_table["mainlist"]) - if index == 0 then + local item + if index > 0 then + item = openSub.itemStore[index] + else + if openSub.itemStore[1].MovieReleaseName ~= "" then + item = openSub.itemStore[1] + else setMessage(lang["mess_no_selection"]) return false end + end openSub.actionLabel = lang["mess_downloading"] display_subtitles() -- reset selection - local item = openSub.itemStore[index] - if openSub.option.downloadBehaviour == 'manual' or not openSub.file.hasInput then local link = "" @@ -1764,6 +1771,11 @@ function download_subtitles() end setMessage(message) + + -- close vlsub window after downloading + if index == 0 then + close() + end end function dump_zip(url, dir, subfileName) From 85ef51847f480046170882c8a8fde81b88a0c451 Mon Sep 17 00:00:00 2001 From: Juuso Date: Wed, 26 Nov 2014 16:03:11 +0200 Subject: [PATCH 2/9] Added keyboard shortcuts for pull-down menu item and most used buttons (search, download, close) Download button downloads first in search list if user didnt select any Automatic search on first load Plugin window closes now straight after download --- vlsub.lua | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 33bdfea..54620ba 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -64,15 +64,15 @@ local options = { int_config = 'Config', int_configuration = 'Configuration', int_help = 'Help', - int_search_hash = 'Search by hash', + int_search_hash = '&Search by hash', int_search_name = 'Search by name', int_title = 'Title', int_season = 'Season (series)', int_episode = 'Episode (series)', int_show_help = 'Show help', int_show_conf = 'Show config', - int_dowload_sel = 'Download selection', - int_close = 'Close', + int_dowload_sel = '&Download selection', + int_close = '&Close', int_ok = 'Ok', int_save = 'Save', int_cancel = 'Cancel', @@ -326,7 +326,7 @@ local select_conf = {} -- Drop down widget / option table association function descriptor() return { - title = "VLsub 0.9.13", + title = "&VLsub 0.9.13", version = "0.9.13", author = "exebetche", url = 'http://www.opensubtitles.org/', @@ -553,6 +553,8 @@ function trigger_menu(dlg_id) dlg = vlc.dialog( openSub.conf.useragent) interface_main() + -- Trigger search after window has appeared + searchHash() elseif dlg_id == 2 then close_dlg() dlg = vlc.dialog( @@ -1656,17 +1658,22 @@ end function download_subtitles() local index = get_first_sel(input_table["mainlist"]) - if index == 0 then - setMessage(lang["mess_no_selection"]) - return false + local item + if index > 0 then + item = openSub.itemStore[index] + else + if openSub.itemStore[1].MovieReleaseName ~= "" then + item = openSub.itemStore[1] + else + setMessage(lang["mess_no_selection"]) + return false + end end openSub.actionLabel = lang["mess_downloading"] display_subtitles() -- reset selection - local item = openSub.itemStore[index] - if openSub.option.downloadBehaviour == 'manual' or not openSub.file.hasInput then local link = "" @@ -1764,6 +1771,11 @@ function download_subtitles() end setMessage(message) + + -- close vlsub window after downloading + if index == 0 then + close() + end end function dump_zip(url, dir, subfileName) From ac4cc25a96ac50cce06a94d018caed87f5464019 Mon Sep 17 00:00:00 2001 From: Juuso Date: Wed, 26 Nov 2014 16:27:46 +0200 Subject: [PATCH 3/9] added possibility to remove ads from subtitles --- vlsub.lua | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 54620ba..c14bf9d 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -318,6 +318,13 @@ local lang_os_to_iso = { vi = "vie" } +local removable_ad_strings = { + 'Advertise your product or brand here', + 'contact www.OpenSubtitles.org today', + 'Support us and become VIP member', + 'to remove all ads from OpenSubtitles.org', + } + local dlg = nil local input_table = {} -- General widget id reference local select_conf = {} -- Drop down widget / option table association @@ -1747,10 +1754,10 @@ function download_subtitles() local stream = vlc.stream(tmpFileURI) local data = "" local subfile = io.open(target, "wb") - - while data do - subfile:write(data) - data = stream:read(65536) + + while data ~= nil do + subfile:write(data .. "\n") + data = filter_ads(stream:readline()) end subfile:flush() @@ -1778,6 +1785,23 @@ function download_subtitles() end end +function filter_ads(data) + + for key,value in ipairs(removable_ad_strings) do + if trim(data) == value then + data = "" + end + end + + return data +end + +function trim(s) + if s then + return s:match'^%s*(.*%S)' or '' + end +end + function dump_zip(url, dir, subfileName) -- Dump zipped data in a temporary file setMessage(openSub.actionLabel..": "..progressBarContent(0)) From c079acd9ea4a15feeefcbc81dfbb4a912c8cf39e Mon Sep 17 00:00:00 2001 From: Juuso Date: Sat, 10 Sep 2016 18:30:49 +0300 Subject: [PATCH 4/9] Updated the README for keyboard shortcuts. Added keyboard shortcut to vlsub in view menu for vlc 2.2.4. --- README.md | 5 ++--- vlsub.lua | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d7f108c..0ad2d4a 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,9 @@ Create a directory "extensions" at this location if it doesn't exists, then extr #### USAGE: * Start Vlc * Start your video -* Click on the menu View > VLSub or VLC > Extension > VLSub on Mac OS X -* Click on "Search by hash" or "Search by name" +* Click on the menu View > VLSub or VLC > Extension > VLSub on Mac OS X. You can also open the menu by pressing Alt+I, then Alt+V * Select a subtitles file on the list -* Click on "Download selection" +* Click on "Download selection" or press Alt+D * That's it, the subtitles should appear on your video. * If you're not happy with your subtitles (wrong sync etc), you can select an other one and click "Download" again, that will erase the previous one and load it automatically. diff --git a/vlsub.lua b/vlsub.lua index c14bf9d..8699254 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -337,7 +337,7 @@ function descriptor() version = "0.9.13", author = "exebetche", url = 'http://www.opensubtitles.org/', - shortdesc = "VLsub"; + shortdesc = "&VLsub"; description = options.translation.int_descr, capabilities = {"menu", "input-listener" } } From b795bd3d4d7a4bc0dedab9898a72e7ae7acc4357 Mon Sep 17 00:00:00 2001 From: Juuso Date: Tue, 23 Oct 2018 10:58:05 +0300 Subject: [PATCH 5/9] Removed ad filtering --- vlsub.lua | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 8699254..4c5a685 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -318,13 +318,6 @@ local lang_os_to_iso = { vi = "vie" } -local removable_ad_strings = { - 'Advertise your product or brand here', - 'contact www.OpenSubtitles.org today', - 'Support us and become VIP member', - 'to remove all ads from OpenSubtitles.org', - } - local dlg = nil local input_table = {} -- General widget id reference local select_conf = {} -- Drop down widget / option table association @@ -1755,9 +1748,9 @@ function download_subtitles() local data = "" local subfile = io.open(target, "wb") - while data ~= nil do - subfile:write(data .. "\n") - data = filter_ads(stream:readline()) + while data do + subfile:write(data) + data = stream:read(65536) end subfile:flush() @@ -1785,23 +1778,6 @@ function download_subtitles() end end -function filter_ads(data) - - for key,value in ipairs(removable_ad_strings) do - if trim(data) == value then - data = "" - end - end - - return data -end - -function trim(s) - if s then - return s:match'^%s*(.*%S)' or '' - end -end - function dump_zip(url, dir, subfileName) -- Dump zipped data in a temporary file setMessage(openSub.actionLabel..": "..progressBarContent(0)) From 4da557f89354b13921d51fcfec9b3ef60fbce60b Mon Sep 17 00:00:00 2001 From: Juuso Date: Tue, 23 Oct 2018 11:04:30 +0300 Subject: [PATCH 6/9] Fixed name and version specs to new format --- vlsub.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 4c5a685..1ab1483 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -322,15 +322,19 @@ local dlg = nil local input_table = {} -- General widget id reference local select_conf = {} -- Drop down widget / option table association +local app_name = "VLsub"; +local app_version = "0.10.2"; +local app_useragent = app_name.." "..app_version; + --[[ VLC extension stuff ]]-- function descriptor() return { - title = "&VLsub 0.9.13", - version = "0.9.13", + title = "&"..app_useragent, + version = app_version, author = "exebetche", url = 'http://www.opensubtitles.org/', - shortdesc = "&VLsub"; + shortdesc = "&"..app_name; description = options.translation.int_descr, capabilities = {"menu", "input-listener" } } From b0899e1ef66b734fc3d7e1f8fdb9b290370f60e7 Mon Sep 17 00:00:00 2001 From: Juuso Date: Tue, 23 Oct 2018 17:43:08 +0300 Subject: [PATCH 7/9] Removed & -markings from plugin names --- vlsub.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 1ab1483..fff3fe4 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -330,11 +330,11 @@ local app_useragent = app_name.." "..app_version; function descriptor() return { - title = "&"..app_useragent, + title = app_useragent, version = app_version, author = "exebetche", url = 'http://www.opensubtitles.org/', - shortdesc = "&"..app_name; + shortdesc = app_name; description = options.translation.int_descr, capabilities = {"menu", "input-listener" } } From e5826c920076a45019be4dead632932af19c712c Mon Sep 17 00:00:00 2001 From: Juuso Date: Tue, 23 Oct 2018 17:43:59 +0300 Subject: [PATCH 8/9] Added hotkey char & back to plugin name --- vlsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlsub.lua b/vlsub.lua index fff3fe4..354ccdb 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -334,7 +334,7 @@ function descriptor() version = app_version, author = "exebetche", url = 'http://www.opensubtitles.org/', - shortdesc = app_name; + shortdesc = "&"..app_name; description = options.translation.int_descr, capabilities = {"menu", "input-listener" } } From caa106dda62f67ab6263b049d025b1ab67c6df6a Mon Sep 17 00:00:00 2001 From: Juuso Date: Tue, 23 Oct 2018 17:54:15 +0300 Subject: [PATCH 9/9] Imported from newer version --- vlsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlsub.lua b/vlsub.lua index 354ccdb..1d5962b 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -1676,7 +1676,7 @@ function download_subtitles() openSub.actionLabel = lang["mess_downloading"] - display_subtitles() -- reset selection + local item = openSub.itemStore[index] if openSub.option.downloadBehaviour == 'manual' or not openSub.file.hasInput then