Skip to content
This repository has been archived by the owner on Oct 14, 2018. It is now read-only.

Commit

Permalink
Fixing torrent_search to work with HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasberti authored and yagop committed Dec 17, 2015
1 parent 44b6ec9 commit 4d7a410
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions plugins/torrent_search.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
--[[ NOT USED DUE TO SSL ERROR
-- See https://getstrike.net/api/
local function strike_search(query)
local strike_base = 'http://getstrike.net/api/v2/torrents/'
local url = strike_base..'search/?phrase='..URL.escape(query)
print(url)
local b,c = http.request(url)
print(b,c)
local search = json:decode(b)
vardump(search)
if c ~= 200 then
return search.message
end
vardump(search)
local results = search.results
local text = 'Results: '..results
local results = math.min(results, 3)
for i=1,results do
local torrent = search.torrents[i]
text = text..torrent.torrent_title
..'\n'..'Seeds: '..torrent.seeds
..' '..'Leeches: '..torrent.seeds
..'\n'..torrent.magnet_uri..'\n\n'
end
return text
end]]--
local https = require ('ssl.https')
local ltn12 = require ("ltn12")

local function search_kickass(query)
local url = 'http://kat.cr/json.php?q='..URL.escape(query)
local b,c = http.request(url)
local data = json:decode(b)
local url = 'https://kat.cr/json.php?q='..URL.escape(query)

local resp = {}

local b,c = https.request
{
url = url,
protocol = "tlsv1",
sink = ltn12.sink.table(resp)
}

resp = table.concat(resp)

local data = json:decode(resp)

local text = 'Results: '..data.total_results..'\n\n'
local results = math.min(#data.list, 5)
Expand Down

0 comments on commit 4d7a410

Please sign in to comment.