thePanz / VLC-Subtitles-Finder

VLC plugin (written in LUA) for subtitles search and download.
13 stars 4 forks source link

Check by file size #1

Open igorgomes opened 12 years ago

igorgomes commented 12 years ago

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

thePanz commented 12 years ago

Hi Igor, thank you for your code.. can you post a pathc (or the complete code) with the GUI changes too?

I'm waiting for VLC to update to LUA 5.2 scripting language, which includes bit operations to code (or look for a code already done) to calculate Opensubtitles HASH codes and avoiding to rely on names/filesizes checks..

Regards

igorgomes commented 12 years ago

Panz, I don't have the complete code! Only these lines... I'm using a Nautilus extension now.

Best!

thePanz commented 12 years ago

Ok, thank you anyway Igor! I found the "Periscope" script for Nautilus, and... it's incredible! :)