From 35b2b813c4ac4b53fef1e5396016458942f1bad1 Mon Sep 17 00:00:00 2001 From: Mondane Date: Wed, 10 Apr 2013 21:49:51 +0200 Subject: [PATCH 1/2] Changed the progress bar style. --- vlsub.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index 9cd530a..d8f5bb4 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -399,7 +399,7 @@ openSub = { setMessage(openSub.actionLabel..": "..progressBarContent(0)) local item = openSub.getInputItem() - + if not item then setError("Please use this method during playing") return false @@ -1000,14 +1000,26 @@ function set_interface() end end +--[[ + Display a progress bar of length progressBarSize. The filled part is calculated + by progressBarSize * pct / 100 . If a percentage of 100 is given, the word 'Done!' + is printed after the progress bar. + + Change in style and adding of 'Done!' proposed by mederi, see http://addons.videolan.org/content/show.php?content=148752 +--]] function progressBarContent(pct) - local content = "" + local content = "" local accomplished = math.ceil(progressBarSize*pct/100) - + local left = progressBarSize - accomplished - content = content .. string.rep ("|", accomplished) + content = content .. string.rep ("-", accomplished) content = content .. "" - content = content .. string.rep ("|", left) + content = content .. string.rep ("-", left) + + if pct == 100 then + content = content .. " Done!" + end + return content end From d87a1a5d5053c403cc4d1d5361af7e0860bf18e3 Mon Sep 17 00:00:00 2001 From: Mondane Date: Wed, 10 Apr 2013 22:00:53 +0200 Subject: [PATCH 2/2] Search for subtitles in default language by file hash on start and added 'Download & close' button. --- vlsub.lua | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/vlsub.lua b/vlsub.lua index d8f5bb4..7e5f627 100644 --- a/vlsub.lua +++ b/vlsub.lua @@ -19,12 +19,20 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + + Changes by Mondane in 0.8.1 + - different style progress bar (thanks to mederi) + - start searching for subtitles with hash method when opening VLSub + - added button 'Download and close' for hash method + - renamed 'Ok' to 'Download' for hash method + - renamed 'Ok' to 'Search or download' for IMDB method + --]] -- Extension description function descriptor() - return { title = "VLsub" ; - version = "0.8" ; + return { title = "VLsub 0.8.1" ; + version = "0.8.1" ; author = "exebetche" ; url = 'http://www.opensubtitles.org/'; shortdesc = "VLsub"; @@ -61,6 +69,12 @@ function activate() openSub.getFileInfo() openSub.getMovieInfo() --~ openSub.request("LogIn") + + -- Automatically start searching for subtitles if there is an item loaded in VLC. + local item = openSub.getInputItem() + if item then + set_interface() + end end function deactivate() @@ -607,6 +621,11 @@ function make_uri(str, encode) end end +function downloadHashAndClose() + searchHash() + close() +end + function searchHash() if not hasAssociatedResult() then openSub.sub.languageid = languages[widget.getVal("language")][2] @@ -626,6 +645,11 @@ function searchHash() end end +function downloadIMDBAndClose() + searchIMDB() + close() +end + function searchIMBD() local title = trim(widget.getVal("title")) local old_title = trim(widget.get("title").value) @@ -1356,8 +1380,9 @@ interface = { { { type = "list", width = 4, id = "hashmainlist" } },{ - { type = "span", width = 2}, - { type = "button", value = "Ok", callback = searchHash }, + { type = "span", width = 1}, + { type = "button", value = "Download and close", callback = downloadHashAndClose }, + { type = "button", value = "Download", callback = searchHash }, { type = "button", value = "Close", callback = close } } } @@ -1376,7 +1401,7 @@ interface = { },{ { type = "label", value = "Episode (series):"}, { type = "text_input", value = openSub.movie.episodeNumber or "", id = "episode" }, - { type = "button", value = "Ok", callback = searchIMBD }, + { type = "button", value = "Search or download", callback = searchIMBD }, { type = "button", value = "Close", callback = close } },{ { type = "list", width = 4, id = "imdbmainlist" }