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

Updated vlsub.lua #1

Closed
wants to merge 2 commits into from
Closed
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
57 changes: 47 additions & 10 deletions vlsub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -399,7 +413,7 @@ openSub = {
setMessage(openSub.actionLabel..": "..progressBarContent(0))

local item = openSub.getInputItem()

if not item then
setError("Please use this method during playing")
return false
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -1000,14 +1024,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 = "<span style='color:#181'>"
local content = "<span style='background-color:green;color:#181'>"
local accomplished = math.ceil(progressBarSize*pct/100)

local left = progressBarSize - accomplished
content = content .. string.rep ("|", accomplished)
content = content .. string.rep ("-", accomplished)
content = content .. "</span>"
content = content .. string.rep ("|", left)
content = content .. string.rep ("-", left)

if pct == 100 then
content = content .. " Done!"
end

return content
end

Expand Down Expand Up @@ -1344,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 }
}
}
Expand All @@ -1364,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" }
Expand Down