PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: c h i l l a on 07 December, 2003, 19:46:48

Title: imdb.freedb
Post by: c h i l l a on 07 December, 2003, 19:46:48
well its nice, but lags the hub, when used,
but its comfortable :)
enjoy.

--imdb.freedb.http-V.1.lua by chilla
--------------------------------------------------------------------------------------------------------------------------
bot = "IFINFO"
ifPrefix = "%!%+%-%?"
cmd1 = "imdb"
cmd2 = "freedb"
ifhelp = "\tPrefixa: ! - + ?\r\n\tSyntax: Prefix\""..cmd1.."\" Movie\r\n\tSyntax: Prefix\""..cmd2.."\" Artist\r\n\tSyntax: Prefix\""..cmd2.."\" Artist Album\r\n"
--------------------------------------------------------------------------------------------------------------------------
-- This shows also an album when search in freedb when set to value 1
showAlbum = 1
--------------------------------------------------------------------------------------------------------------------------
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s["..ifPrefix.."](%S+)" )
if (cmd and strlower(cmd) == strlower(cmd1)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetImdbEntry(str1))
else
curUser:SendData(bot,ifhelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd2)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
local sItem1 = gsub(str1,"%s","%+")
sItem1 = "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&allcats=YES&grouping=none"
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
else
curUser:SendData(bot,ifhelp)
end
return 1
end
end
end
--------------------------------------------------------------------------------------------------------------------------
-- **FUNCS**
--------------------------------------------------------------------------------------------------------------------------
function GetFreeDBEntry(str1,shttp,ret)

local set,httpn,sAlbum,host = 0,"","","www.freedb.org"

GETHTML = "GET /"..shttp.." HTTP/1.1\r\nHost: "..host.."\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect(host, 80)
local msg = ""
local msg2 = ""
if not e then
local line = ""
socket:timeout(2)
socket:send(GETHTML..strchar(13,10))
local handle = openfile("test2.html","w")
while not e do
line1, e = socket:receive("*l")
write(handle,line1.."\r\n")
if strfind(line1,"

(.*)

") then
_,_,sAlbum = strfind(line1,"

(.*)

")
end
if line1 == "" then
while line1 ~= "
" do
line1, e = socket:receive("*l")
write(handle,line1.."\r\n")
if strfind(line1, "(.*)

") then
local _,_, httpt,sname = strfind(line1, "(.*)

")
if set == 0 then
httpn = httpt
set = 1
end
msg = msg.."\tAlbum: "..sname.."        Site:    http://www.freedb.org/"..httpt.."\r\n"
end
if strfind(line1,"(.*)%.%s(%S+)(.*)") then
local _,_,track,length,title = strfind(line1,"(.*)%.%s(%S+)(.*)")
msg2 = msg2.."\t"..track..". "..title.."  ( "..length.." )\r\n"
end
end
end
end
closefile(handle)
socket:close()
end
print(e,i)
if set == 1 and showAlbum == 1 then
msg = msg.."\r\n\r\n"..GetFreeDBEntry("X",httpn,1)
end
if msg ~="" then
msg = "\tSearchItem :   "..str1.."\r\n\r\n"..msg
end
if msg2 ~= "" then
msg2 = "\tAlbum:   "..sAlbum.."\r\n\r\n"..msg2
end
if ret == 1 then
return msg2
else
return msg
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetImdbEntry(sItem)

GETHTML = "GET /Tsearch?title="..sItem.." HTTP/1.1\r\nHost: www.imdb.com\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.imdb.com", 80)
local msg = "\r\n"
if not e then
local line = ""
socket:timeout(2)
socket:send(GETHTML..strchar(13,10))
local handle = openfile("test.html","w")
while not e do
line1, e = socket:receive("*l")
write(handle,line1.."\r\n")
if line1 == "

Movies

" then
line1, e = socket:receive("*l")
write(handle,line1.."\r\n")
while line1 ~= "" do
_,_,httpt,mname = strfind(line1,".*=\"(%S+)\">(.*).*")
if httpt and mname then
msg = msg.."\t"..mname.."       Site:   http://www.imdb.com"..httpt.."\r\n"
end
line1, e = socket:receive("*l")
write(handle,line1.."\r\n")
end

end
end
closefile(handle)
socket:close()
end
return "\tSearched Movie:  "..sItem.."\r\n\r\n\tResults:\r\n"..msg
end
Title:
Post by: c h i l l a on 13 February, 2004, 21:15:22
just a little update, for google type

+google search

will only check google.de  hope it works

--imdb.freedb.http-V.1.3.lua by chilla
--------------------------------------------------------------------------------------------------------------------------
bot = "IFINFO"
ifPrefix = "%!%+%-%?"
cmd1 = "imdb"
cmd2 = "freedb"
cmd3 = "google"
ihelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd1.."\" Movie\r\n"
fhelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd2.."\" Artist:Album\r\n\tSyntax: Prefix\""..cmd2.."\" Category Artist:Album\r\n"
--------------------------------------------------------------------------------------------------------------------------
-- This shows also an album when search in freedb when set to value 1
showAlbum = 1
--This is the maxiumum Socket Timeout time you want to have.
TMax = 3
--------------------------------------------------------------------------------------------------------------------------
Cats = { "blues","classical","country","data","folk","jazz","misc","newage","reggae","rock","soundtrack" }
--------------------------------------------------------------------------------------------------------------------------
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s["..ifPrefix.."](%S+)" )
if (cmd and strlower(cmd) == strlower(cmd1)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetImdbEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetGoogleEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd2)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
local sItem1 = gsub(str1,"%s","%+")
sItem1 = "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=YES&grouping=none"
if strfind(data,"%b<>%s+%S+%s+(%S+)%s+.*") then
_,_,str2,str3 = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
local link = foreach(Cats, function(_,b)
if strlower(str2) == b then
local sItem1 = gsub(str3,"%s","%+")
return "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=NO&cats="..b.."&grouping=none"
end
end)
if link then
curUser:SendData(bot,"Category :   "..str2.."\r\n\r\n"..GetFreeDBEntry(str3,link))
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
str2,str3 = nil,nil
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
else
curUser:SendData(bot,fhelp)
end
return 1
end
end
end
--------------------------------------------------------------------------------------------------------------------------
-- **FUNCS**
--------------------------------------------------------------------------------------------------------------------------
function GetFreeDBEntry(str1,shttp,ret)

local set,httpn,sAlbum,host,genre,year,tracks,ttime = 0,"","","www.freedb.org","-","-","-","-"

GETHTML = "GET /"..shttp.." HTTP/1.1\r\nHost: "..host.."\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect(host, 80)
local msg = ""
local msg2 = ""
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while not e do
line1, e = socket:receive("*l")
if ret == 1 and strfind(line1,"

(.*)

") then
_,_,sAlbum = strfind(line1,"

(.*)

")
elseif ret == 1 and strfind(line1,"genre:%s+(%S+)
") then
_,_,genre = strfind(line1,"genre:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"total time:%s+(%S+)
") then
_,_,ttime = strfind(line1,"total time:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"tracks:%s+(%d+)
") then
_,_,tracks = strfind(line1,"tracks:%s+(%d+)
")
elseif ret == 1 and strfind(line1,"year:%s+(%d+)
") then
_,_,year = strfind(line1,"year:%s+(%d+)
")
end
if line1 == "" then
while line1 ~= "
" do
line1, e = socket:receive("*l")
if strfind(line1, "(.*)

") then
local _,_, httpt,sname = strfind(line1, "(.*)

")
local _,_,genre = strfind(httpt,"%?cat=(%a+)&")
genre = strupper(strsub(genre,1,1))..strsub(genre,2,strlen(genre))
if set == 0 then
httpn = httpt
set = 1
end
msg = msg.."\tGenre: "..genre.."  ::  "..sname.."    ::    Link:    [URL]http://www.freedb.org/[/URL]"..httpt.."\r\n"
elseif ret == 1 and strfind(line1,"(.*)%.%s(%S+)(.*)") then
local _,_,track,length,title = strfind(line1,"(.*)%.%s(%S+)(.*)")
msg2 = msg2.."\t"..track..". "..title.."  ( "..length.." )\r\n"
end
end
break
end
end
socket:close()
else
return "\tServer: "..host.." is currently offline."
end
if set == 1 and showAlbum == 1 then
msg = msg.."\t_______________________\r\n\r\n"..GetFreeDBEntry("X",httpn,1)
end
if msg ~="" then
msg = "\tSearchItem :   "..str1.."\r\n\r\n"..msg
else
msg = "\tNothing found for:  "..str1.."\r\n"
end
if msg2 ~= "" then
msg2 = "\tAlbum:  "..sAlbum.."\r\n\tGenre:  "..genre..", Year:  "..year..", Tracks:  "..tracks..", Total Time:  "..ttime.."\r\n\r\n"..msg2
end
if ret == 1 then
return msg2
else
return msg
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetImdbEntry(sItem)

local sItem1 = gsub(sItem," ","%%20")

GETHTML = "GET /find?tt=on;nm=on;mx=20;q="..sItem1.." HTTP/1.1\r\nHost: [URL]www.imdb.com\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.imdb.com", 80)
local msg = "\r\n"
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")
if strsub(line1,3,22) == "Exact Matches" then
line1, e = socket:receive("*l")
while (not e) and (line1 ~= "  ") do
local _,_,httpt,mname = strfind(line1,"^    1. (.*)")
if httpt and mname then
msg = msg.."\t"..mname.."   ::   Link:   [URL]http://www.imdb.com[/URL]"..httpt.."\r\n"
end
line1, e = socket:receive("*l")
end
break
end
end
socket:close()
else
return "\tServer: [URL]www.imdb.com[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tSearched Movie:  "..sItem.."\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetGoogleEntry(sItem)

local sItem1 = gsub(sItem," ","+")

GETHTML = "GET /search?q="..sItem1.."&ie=UTF-8&oe=UTF-8&hl=de&btnG=Google+Suche HTTP/1.1\r\nHost: [URL]www.google.de\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.google.de", 80)
local msg = "\r\n"
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")
if strfind(line1,"

(.*)") then
local _,_,text1,text2 = strfind(line1,"

(.*)")
text1 = gsub(text1,"[<>]","")
text1 = gsub(text1,"/b","/")
text2 = gsub(text2,"%b<>","")
msg = msg.."\t- "..text2.."\r\n\tLink:   "..text1.."\r\n\r\n"
elseif strfind(line1,"") then
break
end
end
socket:close()
else
return "\tServer: [URL]www.google.de[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tGoogle Search:  "..sItem.."\r\n\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end

end

Title:
Post by: [NL]Pur on 20 February, 2004, 20:57:28
nice one :)
Title:
Post by: [P]Tomix on 12 December, 2004, 14:59:58
gr8 idea c h i l l a ;D

but could u modify(update?) your script....

imdb part :
   notice that : it's returning only one (first) result but it can be more Exact Matches  (eg.http://www.imdb.com/find?q=terminator;tt=on;nm=on;mx=20)

--replace line : GETHTML = "GET /find?tt=on;nm=on;mx=20;q="..sItem1.." HTTP/1.1\r\nHost: //www.imdb.com\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n" with : GETHTML = "GET /find?q="..sItem1..";tt=on;nm=on;mx=20 HTTP/1.1\r\nHost: //www.imdb.com\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

--could u modify your code. when itll show Partial Matches
it can be more powerfull

--line: local _,_,httpt,mname = strfind(line1,"^    1. (.*)") sometimes it not looks like that.....(i can find 'terminator' cause html code looks like: 1. The Terminator (1984)
 aka "Terminator"
 - line dont match....)

pzz m8 and ill hope u do some changes ;]

                                                          //Tomix
Title:
Post by: chill on 13 December, 2004, 20:19:31
ty, about the code, you should know that the hub stops when, the socket is called.

But I'll try, if you really need it else
try to type
/imdb title in your dc client
Title:
Post by: [P]Tomix on 15 December, 2004, 18:23:46
hi,

itll be gr8 to see new version,
'most powerful' - i just compare imdb part with freedb one (imdb :- Exact Matches (about 1-5 matches) + Partial Matches (10-15) its still less that 100 matches with freedb {maybe few changes would be good with freebd part of the script (if itll get more than 50 results itll be stop the gethtml and return "too many results...")} ...... i know that it stops hub...i've tested it ;p
Title:
Post by: chill on 18 December, 2004, 01:19:50
I didn't change the freedb part cause, sometimes the title one searches for is right in the last few

--imdb.freedb.http-V.1.4.lua by chilla
--Better search results with imdb thx to Tomix
--------------------------------------------------------------------------------------------------------------------------
bot = "IFINFO"
ifPrefix = "%!%+%-%?"
cmd1 = "imdb"
cmd2 = "freedb"
cmd3 = "google"
ihelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd1.."\" Movie\r\n"
fhelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd2.."\" Artist:Album\r\n\tSyntax: Prefix\""..cmd2.."\" Category Artist:Album\r\n"
--------------------------------------------------------------------------------------------------------------------------
-- This shows also an album when search in freedb when set to value 1
showAlbum = 1
--This is the maxiumum Socket Timeout time you want to have.
TMax = 3
--------------------------------------------------------------------------------------------------------------------------
Cats = { "blues","classical","country","data","folk","jazz","misc","newage","reggae","rock","soundtrack" }
--------------------------------------------------------------------------------------------------------------------------
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s["..ifPrefix.."](%S+)" )
if (cmd and strlower(cmd) == strlower(cmd1)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetImdbEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetGoogleEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd2)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
local sItem1 = gsub(str1,"%s","%+")
sItem1 = "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=YES&grouping=none"
if strfind(data,"%b<>%s+%S+%s+(%S+)%s+.*") then
_,_,str2,str3 = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
local link = foreach(Cats, function(_,b)
if strlower(str2) == b then
local sItem1 = gsub(str3,"%s","%+")
return "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=NO&cats="..b.."&grouping=none"
end
end)
if link then
curUser:SendData(bot,"Category :   "..str2.."\r\n\r\n"..GetFreeDBEntry(str3,link))
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
str2,str3 = nil,nil
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
else
curUser:SendData(bot,fhelp)
end
return 1
end
end
end
--------------------------------------------------------------------------------------------------------------------------
-- **FUNCS**
--------------------------------------------------------------------------------------------------------------------------
function GetFreeDBEntry(str1,shttp,ret)

local set,httpn,sAlbum,host,genre,year,tracks,ttime = 0,"","","www.freedb.org","-","-","-","-"

local GETHTML = "GET /"..shttp.." HTTP/1.1\r\nHost: "..host.."\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect(host, 80)
local msg = ""
local msg2 = ""
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while not e do
line1, e = socket:receive("*l")
if ret == 1 and strfind(line1,"

(.*)

") then
_,_,sAlbum = strfind(line1,"

(.*)

")
elseif ret == 1 and strfind(line1,"genre:%s+(%S+)
") then
_,_,genre = strfind(line1,"genre:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"total time:%s+(%S+)
") then
_,_,ttime = strfind(line1,"total time:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"tracks:%s+(%d+)
") then
_,_,tracks = strfind(line1,"tracks:%s+(%d+)
")
elseif ret == 1 and strfind(line1,"year:%s+(%d+)
") then
_,_,year = strfind(line1,"year:%s+(%d+)
")
end
if line1 == "" then
while line1 ~= "
" do
line1, e = socket:receive("*l")
if strfind(line1, "(.*)

") then
local _,_, httpt,sname = strfind(line1, "(.*)

")
local _,_,genre = strfind(httpt,"%?cat=(%a+)&")
genre = strupper(strsub(genre,1,1))..strsub(genre,2,strlen(genre))
if set == 0 then
httpn = httpt
set = 1
end
msg = msg.."\tGenre: "..genre.."  ::  "..sname.."    ::    Link:    [URL]http://www.freedb.org/[/URL]"..httpt.."\r\n"
elseif ret == 1 and strfind(line1,"(.*)%.%s(%S+)(.*)") then
local _,_,track,length,title = strfind(line1,"(.*)%.%s(%S+)(.*)")
msg2 = msg2.."\t"..track..". "..title.."  ( "..length.." )\r\n"
end
end
break
end
end
socket:close()
else
return "\tServer: "..host.." is currently offline."
end
if set == 1 and showAlbum == 1 then
msg = msg.."\t_______________________\r\n\r\n"..GetFreeDBEntry("X",httpn,1)
end
if msg ~="" then
msg = "\tSearchItem :   "..str1.."\r\n\r\n"..msg
else
msg = "\tNothing found for:  "..str1.."\r\n"
end
if msg2 ~= "" then
msg2 = "\tAlbum:  "..sAlbum.."\r\n\tGenre:  "..genre..", Year:  "..year..", Tracks:  "..tracks..", Total Time:  "..ttime.."\r\n\r\n"..msg2
end
if ret == 1 then
return msg2
else
return msg
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetImdbEntry(sItem)

local sItem1 = gsub(sItem," ","%%20")

local GETHTML = "GET /find?q="..sItem1..";tt=on;nm=on;mx=20 HTTP/1.1\r\nHost: [URL]www.imdb.com\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.imdb.com", 80)
local msg = "\r\n"
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")
if strsub(line1,3,22) == "Exact Matches" then
line1, e = socket:receive("*l")
while (not e) and (line1 ~= "  ") do

local _,_,httpt,mname = strfind(line1,"^%s+%b<>%b<>%d%. %b<>%b<><%w href=\"(%S+)\">([^<]+)")
   
if httpt and mname then
msg = msg.."\t"..mname.."   ::   Link:   [URL]http://www.imdb.com[/URL]"..httpt.."\r\n"
end
line1, e = socket:receive("*l")
end
break
end
end
socket:close()
else
return "\tServer: [URL]www.imdb.com[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tSearched Movie:  "..sItem.."\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetGoogleEntry(sItem)

local sItem1 = gsub(sItem," ","+")

local GETHTML = "GET /search?q="..sItem1.."&ie=UTF-8&oe=UTF-8&hl=de&btnG=Google+Suche HTTP/1.1\r\nHost: [URL]www.google.de\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.google.de", 80)
local msg = "\r\n"
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")
if strfind(line1,"

(.*)") then
local _,_,text1,text2 = strfind(line1,"

(.*)")
text1 = gsub(text1,"[<>]","")
text1 = gsub(text1,"/b","/")
text2 = gsub(text2,"%b<>","")
msg = msg.."\t- "..text2.."\r\n\tLink:   "..text1.."\r\n\r\n"
elseif strfind(line1,"") then
break
end
end
socket:close()
else
return "\tServer: [URL]www.google.de[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tGoogle Search:  "..sItem.."\r\n\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end

end

Title:
Post by: TTB on 02 January, 2005, 03:03:59
Hi,

about the imdb part... I was just checking out this script, but I don't get any results with the imdb command...:

Command1: !imdb return of the king
[03:01:32]    Nothing found for:  return of the king

Command2: !imdb speed
[03:01:37]    Nothing found for:  speed

Did I do something wrong?

Thanx...

some extra info:
eh... I have found this in a hub:

<[wur.nl]blaat> !imdb speed
<[BOT]RulezPatrol> imdb query for ``speed'': Speed (1994)
Jan de Bont ][ Action/Thriller ][ 116 min ][ 7.1 by 30,865
http://us.imdb.com/title/tt0111257/

maybe you can do something with it....
Title:
Post by: chill on 02 January, 2005, 16:37:00
hmm..
that bot sucked anyways, lol
Title:
Post by: TTB on 03 January, 2005, 00:31:21
Hi,

I hope you will take a look @ it again... I'm running a DVD hub, so this part (IMDB) is very interesting :)

Hope you will  :P

Thanx
Title:
Post by: bastya_elvtars on 03 January, 2005, 00:38:46
ain't there a /imdb command in DC++?
Title:
Post by: TTB on 03 January, 2005, 00:40:55
Yeah there sure is...
But it is very nice to have it with this commands... the freedb and the google part works! It is almost 100% working, but only the imdb part doesn't work. It is almost finished... Why not finishing it...?!
Title:
Post by: bastya_elvtars on 03 January, 2005, 00:44:16
http://www.plop.nl/ptokaxbots/Pur/imdb.rar
Title:
Post by: TTB on 03 January, 2005, 01:15:03
Well... this bot answers also with 0 results:


[01:11:47] <[bot]iMDb>  Find something!
[01:11:47] <[bot]iMDb> ?????????????
[01:11:47] <[bot]iMDb> Results for: speed&sort=smart&type=regexp&tv=off&from_year1890&to_year2010
[01:11:47] <[bot]iMDb> ????????????????????????????????????????????????????????
[01:11:47] <[bot]iMDb>  ________________________________________________________
[01:11:47] <[bot]iMDb>
[01:11:47] <[bot]iMDb>   ____________
[01:11:47] <[bot]iMDb>  End of Results
[01:11:48] <[bot]iMDb>   ????????????

On IE it wil give a good result: http://www.imdb.com/find?q=speed&sort=smart&type=regexp&tv=off&from_year1890&to_year2010

But this script also doesn't work the way it should work :(  (or do I something wrong?)


Any other options?

Thanx
Title:
Post by: bastya_elvtars on 03 January, 2005, 01:41:51
scriptz are old, maybe something has changed on IMDB.

btw loooool you use ie? ;p
Title:
Post by: TTB on 03 January, 2005, 02:14:56
Hi

gheheh, yeah, I use IE  :(

well... most of the people here should use another client instead, but it works fine to me (yeahyeah... shame on me, I do, really do hate M$!)

Thanx for your quick reply's. Maybe there is still someone who wanna help me out with this.

Thanx all LUA programmers for doing such a great job for all hubowners  8)

bye
Title:
Post by: bastya_elvtars on 03 January, 2005, 02:32:28
well i am a total http n00b so i would gladly help you if i could :(

really sorry maybe i will read after soon but i am busy nowadays. i will fix it then.

cheers
Title:
Post by: chill on 03 January, 2005, 16:13:03
TTB try this one

--imdb.freedb.http-V.1.4.lua by chilla
--Better search results with imdb thx to Tomix
--------------------------------------------------------------------------------------------------------------------------
bot = "IFINFO"
ifPrefix = "%!%+%-%?"
cmd1 = "imdb"
cmd2 = "freedb"
cmd3 = "google"
ihelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd1.."\" Movie\r\n"
fhelp = "\tPrefixes: ! - + ?\r\n\r\n\tSyntax: Prefix\""..cmd2.."\" Artist:Album\r\n\tSyntax: Prefix\""..cmd2.."\" Category Artist:Album\r\n"
--------------------------------------------------------------------------------------------------------------------------
-- This shows also an album when search in freedb when set to value 1
showAlbum = 1
--This is the maxiumum Socket Timeout time you want to have.
TMax = 3
--------------------------------------------------------------------------------------------------------------------------
Cats = { "blues","classical","country","data","folk","jazz","misc","newage","reggae","rock","soundtrack" }
--------------------------------------------------------------------------------------------------------------------------
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s["..ifPrefix.."](%S+)" )
if (cmd and strlower(cmd) == strlower(cmd1)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetImdbEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd3)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
curUser:SendData(bot,GetGoogleEntry(str1))
else
curUser:SendData(bot,ihelp)
end
return 1
elseif (cmd and strlower(cmd) == strlower(cmd2)) then
local _,_,str1 = strfind(data,"%b<>%s+%S+%s+(.*)")
if str1 then
local sItem1 = gsub(str1,"%s","%+")
sItem1 = "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=YES&grouping=none"
if strfind(data,"%b<>%s+%S+%s+(%S+)%s+.*") then
_,_,str2,str3 = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
local link = foreach(Cats, function(_,b)
if strlower(str2) == b then
local sItem1 = gsub(str3,"%s","%+")
return "freedb_search.php?words="..sItem1.."&allfields=NO&fields=artist&fields=title&allcats=NO&cats="..b.."&grouping=none"
end
end)
if link then
curUser:SendData(bot,"Category :   "..str2.."\r\n\r\n"..GetFreeDBEntry(str3,link))
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
str2,str3 = nil,nil
else
curUser:SendData(bot,GetFreeDBEntry(str1,sItem1))
end
else
curUser:SendData(bot,fhelp)
end
return 1
end
end
end
--------------------------------------------------------------------------------------------------------------------------
-- **FUNCS**
--------------------------------------------------------------------------------------------------------------------------
function GetFreeDBEntry(str1,shttp,ret)

local set,httpn,sAlbum,host,genre,year,tracks,ttime = 0,"","","www.freedb.org","-","-","-","-"

local GETHTML = "GET /"..shttp.." HTTP/1.1\r\nHost: "..host.."\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect(host, 80)
local msg = ""
local msg2 = ""
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while not e do
line1, e = socket:receive("*l")
if ret == 1 and strfind(line1,"

(.*)

") then
_,_,sAlbum = strfind(line1,"

(.*)

")
elseif ret == 1 and strfind(line1,"genre:%s+(%S+)
") then
_,_,genre = strfind(line1,"genre:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"total time:%s+(%S+)
") then
_,_,ttime = strfind(line1,"total time:%s+(%S+)
")
elseif ret == 1 and strfind(line1,"tracks:%s+(%d+)
") then
_,_,tracks = strfind(line1,"tracks:%s+(%d+)
")
elseif ret == 1 and strfind(line1,"year:%s+(%d+)
") then
_,_,year = strfind(line1,"year:%s+(%d+)
")
end
if line1 == "" then
while line1 ~= "
" do
line1, e = socket:receive("*l")
if strfind(line1, "(.*)

") then
local _,_, httpt,sname = strfind(line1, "(.*)

")
local _,_,genre = strfind(httpt,"%?cat=(%a+)&")
genre = strupper(strsub(genre,1,1))..strsub(genre,2,strlen(genre))
if set == 0 then
httpn = httpt
set = 1
end
msg = msg.."\tGenre: "..genre.."  ::  "..sname.."    ::    Link:    [URL]http://www.freedb.org/[/URL]"..httpt.."\r\n"
elseif ret == 1 and strfind(line1,"(.*)%.%s(%S+)(.*)") then
local _,_,track,length,title = strfind(line1,"(.*)%.%s(%S+)(.*)")
msg2 = msg2.."\t"..track..". "..title.."  ( "..length.." )\r\n"
end
end
break
end
end
socket:close()
else
return "\tServer: "..host.." is currently offline."
end
if set == 1 and showAlbum == 1 then
msg = msg.."\t_______________________\r\n\r\n"..GetFreeDBEntry("X",httpn,1)
end
if msg ~="" then
msg = "\tSearchItem :   "..str1.."\r\n\r\n"..msg
else
msg = "\tNothing found for:  "..str1.."\r\n"
end
if msg2 ~= "" then
msg2 = "\tAlbum:  "..sAlbum.."\r\n\tGenre:  "..genre..", Year:  "..year..", Tracks:  "..tracks..", Total Time:  "..ttime.."\r\n\r\n"..msg2
end
if ret == 1 then
return msg2
else
return msg
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetImdbEntry(sItem)

local sItem1 = gsub(sItem," ","%%20")

--http://www.imdb.com/find?q=speed;tt=on;nm=on;mx=20

local GETHTML = "GET /find?q="..sItem1..";tt=on;nm=on;mx=20 HTTP/1.1\r\nHost: [URL]www.imdb.com\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.imdb.com", 80)
local msg = "\r\n"
if not e then

local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")

if strfind(line1,"Popular Titles") then


--href="/title/tt0111257/?fr=c2l0ZT1kZnxteD0yMHxzZz0xfGxtPTIwMHx0dD1vbnxwbj0wfHE9c3BlZWR8aHRtbD0xfG5tPW9u;fc=1;ft=17;fm=1">Speed (1994)

local httplink, title, year = "","",""

while httplink and line1 do

_,_,httplink, title, year, rest = strfind(line1,"href=\"([^%?]+)%S+\">([^<]+)%b<>([^<]+)(.*)")

if httplink then

msg = msg.."\t"..title..", "..year.."   ::   Link:   [URL]http://www.imdb.com[/URL]"..httplink.."\r\n"
end

line1 = rest

end
break
end
end
socket:close()
else
return "\tServer: [URL]www.imdb.com[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tSearched Movie:  "..sItem.."\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end
end
--------------------------------------------------------------------------------------------------------------------------
function GetGoogleEntry(sItem)

local sItem1 = gsub(sItem," ","+")

local GETHTML = "GET /search?q="..sItem1.."&ie=UTF-8&oe=UTF-8&hl=de&btnG=Google+Suche HTTP/1.1\r\nHost: [URL]www.google.de\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

socket, e = connect("www.google.de", 80)
local msg = "\r\n"
if not e then
local line1 = ""
socket:timeout(TMax)
socket:send(GETHTML..strchar(13,10))
while (not e) and (line1) do
line1, e = socket:receive("*l")
if strfind(line1,"

(.*)") then
local _,_,text1,text2 = strfind(line1,"

(.*)")
text1 = gsub(text1,"[<>]","")
text1 = gsub(text1,"/b","/")
text2 = gsub(text2,"%b<>","")
msg = msg.."\t- "..text2.."\r\n\tLink:   "..text1.."\r\n\r\n"
elseif strfind(line1,"") then
break
end
end
socket:close()
else
return "\tServer: [URL]www.google.de[/URL] is currently offline."
end
if msg ~="\r\n" then
return "\tGoogle Search:  "..sItem.."\r\n\r\n\tResults:\r\n"..msg
else
return "\tNothing found for:  "..sItem.."\r\n"
end

end

Title:
Post by: TTB on 03 January, 2005, 17:48:44
Hi,

thanx for your reply!! It seems to work now (line 161 should have --   ;-)  )

I will put it online, and will reply within a couple of days... I think it will do the job :D

Thanx!!!
Title:
Post by: TTB on 08 January, 2005, 20:53:25
Chilla,

I have not any problems yet with the script, it works very good... (I said I will reply in a couple of days).

Thanx for changing the script  8)


Bye
Title:
Post by: chill on 09 January, 2005, 10:10:05
no problem, and thx for testing :)
just let me know when it isn't working anymore
Title: Quick question
Post by: BrokenBrick on 01 August, 2005, 22:18:13
Not sure if there is anyone else intereted in this but anyways, I'd like to mod this script to search the BillBoard Top40 charts.  While this is an easy adaptation, the real meat of it comes in where the script must search the hub for entries in the charts in intervals, say, 1 album every 5 minutes and kick/temp ban users sharing it. This script has a very valuable purpose in that the RIAA has henceforth been mostly worried about users/hubs sharing content on the top40 charts.  To avoid legal retrobution, I had the idea of modding this script to serve this function.

An easier way might be to just set up a file that one of the OP's would have to update with the BBTop40 albums every day, and a script that would use the file, much like the SearchKick script, and rid the hub of users that matched it.  Of course it'd be much cooler if it was web based :)

Another more complicated option would be to search RIAA Radar, which lists artists/albums affiliation with the RIAA.  However, because the script would have to browse file-lists and search for artits that a user is sharing this would most likely work better as a modded dc++ client.  However, it would keep your hub totally free from RIAA content.  Anyways, orry this is such a long message, if anyone thinks this sounds interesting, and that it could be adapted deom the imdb script, then tell me all about it.
Title:
Post by: uffetjur on 02 August, 2005, 17:04:13
getting errors with this script: line 319 `=?expected near `;

tried the rared and the latest published ones