[vlc-devel] Fwd: Re-ask [PATCH] Add VLSub feature: Download multiple subtitles

Alon sirotaalon at gmail.com
Tue Aug 25 05:12:12 CEST 2020


I didn't get a response about this patch that I sent on 12.8.20,

could you please review it?

Thanks,

Alon

-------- Forwarded Message --------
Subject: 	[PATCH] Add VLSub feature: Download multiple subtitles
Date: 	Tue, 11 Aug 2020 18:20:21 +0000
From: 	Alon Sirota <sirotaalon at gmail.com>
To: 	vlc-devel at videolan.org
CC: 	Alon Sirota <sirota.alon at gmail.com>



All selected subtitles are now downloaded, instead of only one.

Change 'get_first_sel' function to return ALL selected subtitles
instead of only one, and refactored name to 'get_all_sel'.

Change 'download_subtitles' function to iterate over 'get_all_sel'
returned table instead of downloading the only subtitle from old 
'get_first_sel'.
---
share/lua/extensions/VLSub.lua | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index 2edc73ecdc..ceb49e302d 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -1429,12 +1429,15 @@ function display_subtitles()
lang["mess_no_res"])
end
-function get_first_sel(list)
+ function get_all_sel(list)
local selection = list:get_selection()
+ local indexes = {}
+ local i = 1 -- key counter
for index, name in pairs(selection) do
- return index
+ indexes[i] = index
+ i = i + 1
end
- return 0
+ return indexes
end
function find_subtitle_in_archive(archivePath, subfileExt)
@@ -1453,18 +1456,18 @@ function find_subtitle_in_archive(archivePath, 
subfileExt)
end
function download_subtitles()
- local index = get_first_sel(input_table["mainlist"])
-
- if index == 0 then
+ local indexes = get_all_sel(input_table["mainlist"])
+ if #indexes == 0 then -- if no subtitles selected
setMessage(lang["mess_no_selection"])
return false
end
-
openSub.actionLabel = lang["mess_downloading"]
display_subtitles() -- reset selection
- local item = openSub.itemStore[index]
+ -- for each subtitle index
+ for _, index in pairs(indexes) do
+ item = openSub.itemStore[index]
if openSub.option.downloadBehaviour == 'manual'
or not openSub.file.hasInput then
@@ -1581,6 +1584,7 @@ function download_subtitles()
setMessage(message)
end
+end
function dump_zip(url, dir, subfileName)
-- Dump zipped data in a temporary file

-- 
2.28.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200825/c624153a/attachment.html>


More information about the vlc-devel mailing list