thePanz/VLC-Subtitles-Finder — Issue #1: Check by file size
Author: igorgomes
Created: 2011-11-26 16:26:53+00:00
State: open

An example to add an option to check by file size. But need to be created a radio button to change from name to file size.

function urlOpenSub(search_term,lang)
-- base = "http://api.opensubtitles.org/xml-rpc"
-- lang = "eng"

if lang == "all" then
lang ="en"
end

local item = vlc.input.item()
local path = item:uri()
vlc.msg.dbg("File path "..path.."")
local filename = vlc.strings.decode_uri(string.gsub(path,"file://",""))
vlc.msg.dbg("File path "..filename.."")
local filesize = vlc.net.stat(filename).size
vlc.msg.dbg("Filesize "..filesize.." Kb ")

base = "http://api.opensubtitles.org/"..lang.."/search/"
-- if(lang) then base = base .. "sublanguageid-" .. lang .. "/"
search_term = string.gsub(search_term, "%%", "%%37")
search_term = string.gsub(search_term, " ", "%%20")
-- return base .. "moviename-" .. search_term .. "/simplexml"
return base .. "moviebytesize-" .. filesize .. "/simplexml"
-- http://api.opensubtitles.org/en/search/moviename- .. search_term .. /simplexml
end