Skip to content

Commit

Permalink
Merge pull request #163 from varjolintu/download_fix
Browse files Browse the repository at this point in the history
Download fix
  • Loading branch information
exebetche authored Jan 19, 2017
2 parents 6d8d6f6 + 5750265 commit 657895d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions vlsub.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
--[[
VLSub Extension for VLC media player 1.1 and 2.0
Copyright 2013 Guillaume Le Maout
Authors: Guillaume Le Maout
Contact:
http://addons.videolan.org/messages/?action=newmessage&username=exebetche
Bug report: http://addons.videolan.org/content/show.php/?content=148752
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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.
Expand Down Expand Up @@ -324,7 +320,7 @@ 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.1";
local app_version = "0.10.2";
local app_useragent = app_name.." "..app_version;

--[[ VLC extension stuff ]]--
Expand Down Expand Up @@ -1166,7 +1162,7 @@ openSub = {
conf = {
url = "http://api.opensubtitles.org/xml-rpc",
path = nil,
HTTPVersion = "1.0",
HTTPVersion = "1.1",
userAgentHTTP = app_useragent,
useragent = app_useragent,
translations_avail = {},
Expand Down Expand Up @@ -1923,6 +1919,7 @@ function http_req(host, port, request)

if not header then
headerStr, body = buf:match("(.-\r?\n)\r?\n(.*)")

if headerStr then
header = parse_header(headerStr);
status = tonumber(header["statuscode"]);
Expand All @@ -1944,7 +1941,7 @@ function http_req(host, port, request)
chunk_size = tonumber(chunk_size_hex,16)
chunk_content_len = chunk_content:len()
chunk_remaining = chunk_size-chunk_content_len

while chunk_content_len > chunk_size do
body = body..chunk_content:sub(0, chunk_size)
buf = chunk_content:sub(chunk_size+2)
Expand All @@ -1960,7 +1957,6 @@ function http_req(host, port, request)
chunk_size = tonumber(chunk_size_hex,16)
chunk_content_len = chunk_content:len()
chunk_remaining = chunk_size-chunk_content_len

end

if chunk_size == 0 then
Expand All @@ -1969,10 +1965,15 @@ function http_req(host, port, request)
end

if contentLength then
bodyLenght = #body
pct = bodyLenght / contentLength * 100
if #body == 0 then
bodyLength = #buf
else
bodyLength = #body
end

pct = bodyLength / contentLength * 100
setMessage(openSub.actionLabel..": "..progressBarContent(pct))
if bodyLenght >= contentLength then
if bodyLength >= contentLength then
break
end
end
Expand Down

0 comments on commit 657895d

Please sign in to comment.