local find,len,lower,match = string.find,string.len,string.lower,string.match local function GetAnswer(url) return io.popen('curl.exe -s "'..url..'"','rb'):read("*all") end -- get page content local function Magnet(url) -- string processor if url and type(url)=='string' then local urll=lower(url) local chksum=match(urll,':btih:(%x+)') or match(urll,'^(%x+)$') if chksum and chksum:len()==40 then -- send magnet to uTorrent local link='magnet:?xt=urn:btih:'..chksum local appPath=win.GetEnv("APPDATA")..'\\uTorrent\\uTorrent.exe' win.ShellExecute(nil,nil,'"'..appPath..'"','"'..link..'"',nil,0) else -- send magnet to GreyLink chksum=match(urll,':tiger:([%d%l]+)') if chksum and len(chksum)==39 then local appPath=win.GetEnv("PROGRAMFILES")..'\\DC++\\GreyLink.exe' win.ShellExecute(nil,nil,'"'..appPath..'"','/magnet "'..arg[1]..'"',nil,0) end end end end local url=arg[1] if url and (type(url)=='string') then if find(url,'^%d+$') then url='https://rutracker.org/forum/viewtopic.php?t='..url -- rutracker.org elseif find(lower(url),'^https?://newstudio%.tv/') then url=url..'a' -- newstudio.tv 404 patch end if find(lower(url),'^https?:') then Magnet(match(lower(GetAnswer(url)),'magnet:%?xt=ur[:%l]+:%l+:%x+')) else Magnet(url) end end |