IMDB
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

IMDB

Started by dodgeviper, 14 November, 2006, 00:00:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dodgeviper

can anyone convert the following script to 5.1

-- IMDBBOT By [NL]Pur and GoldMember 
-- last updated: 8 juni 2003


MainBotName = "[bot]Security" -- Rename to match your Main hub bot
BotName = "[bot]iMDb" 
TimeSpanInMinutes = 30

-- Commands --
cmd1 = "?search"             -- <searchstring multiple words>
cmd2 = "?topmovies"          -- no arguments
cmd4 = "?restrict"           -- arguments <tv> <movie> <both>
cmd5 = "?settings"           -- no arguments
cmd6 = "?sort"               -- arguments <smart>  - best search matches first
                             --           <alpha>  - alphabetically
                             --           <chrono> - chronologically
cmd7 = "?type"               -- arguments <regexp> - Regular expression
                             --           <fuzzy>  - fuzzy search
                             --           <word>   - word(s)
cmd8 = "?fromyear"           -- argument search from which year
cmd9 = "?toyear"             -- argument search to which year
cmda = "?help" 

-- Default Settings --
RegisterBot = "PM"           -- PM = Results in PM , MainChat = Results in Main Chat
usetimer = "0"               -- 1 = Updates of Top15 with use of the timer , 0 = Updates when command ?topmovies is used
searchfor = '&tv=only'
sorts = '&sort=smart'
type = '&type=substring'
fromyear = '&from_year1890'
toyear = '&to_year2010'


function Main()
  if (RegisterBot=="PM") then
    frmHub:RegBot(BotName)
  else
    frmHub:UnregBot(BotName)
  end

  SendPmToOps(MainBotName,date("iMDb Activated [%d %B %Y  l %X] ("..RegisterBot.." Mode)"))
  SetTimer(TimeSpanInMinutes*60000) 
  StartTimer() 
end

function OnTimer() 
  if (usetimer=="1") then
    getNews1()
  end
end 


function Get1Arg(data)  
  s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
  return arg
end

function wr(target,text)
  target:SendPM(BotName,text)
end

function DataArrival(curUser,data) 
if (strsub(data, 1, 1) == "<") then 
    data = strsub(data,1,strlen(data)-1) 

    if (strfind(strlower(data), strlower(cmd1))) then 
      arg = Get1Arg(data)
      if (arg==nil) then       
      else
        sp = strchar(32)
        arg = gsub(arg, sp, '+')
        findNews(curUser,arg..sorts..type..searchfor..fromyear..toyear)
      end
    end

    if (strfind(strlower(data), strlower(cmd2))) then 
      if (usetimer=="0") then 
         getNews1()
      end
      headpm(curUser)
      readfile(curUser,"top15.txt")
    end
 
    if (strfind(strlower(data), strlower(cmda))) then 
      readfile(curUser,"helpimdb.txt")
    end
  
    if (getcmd(data,cmd4)==1) and (curUser.bOperator) then
       if (arg=='movie') then searchfor='&tv=off' end
       if (arg=='both') then searchfor='&tv=both' end
       if (arg=='tv') then searchfor='&tv=only' end
    end

    if (getcmd(data,cmd6)==1) and (curUser.bOperator)then
        if (arg=='smart') then sorts='&sort=smart' end
        if (arg=='alpha') then sorts='&sort=alpha' end
        if (arg=='chrono') then sorts='&sort=chrono' end
    end  

    if (getcmd(data,cmd7)==1) and (curUser.bOperator) then
      if (arg=='regexp') then type='&type=regexp' end
      if (arg=='fuzzy') then type='&type=fuzzy' end
      if (arg=='word') then type='&type=substring' end
    end

    if (getcmd(data,cmd8)==1) and (curUser.bOperator) then
      toyear = "&from_year"..arg
    end

    if (getcmd(data,cmd9)==1) and (curUser.bOperator) then
      toyear = "&to_year"..arg
    end
   
    if (strfind(strlower(data), strlower(cmd5))) then sett(curUser) end   
end
end

function getcmd(data,md)
  getmd=0
  if (strfind(strlower(data), strlower(md))) then 
      arg = Get1Arg(data)
      if (arg==nil) then       
      else     
        getmd=1
        return getmd
      end
    end
end

function sett(target)
     readfile(target,"settings.txt")

     if (searchfor=='&tv=off') then 
       res = "			Movie"
     elseif (searchfor=='&tv=both') then
       res = "			Both"
     elseif (searchfor=='&tv=only') then
       res = "			Tv"
     end
     wr(target,"Restrict is set for: "..res)

     if (sorts=='&sort=smart') then 
       sort = "		Best search matches first"
     elseif (sorts=='&sort=alpha') then
       sort = "		Alphabetically"
     elseif (sorts=='&sort=chrono') then
       sort = "		Chronologically"
     end
     wr(target,"Sort method is set for: "..sort)

     if (type=='&type=regexp') then 
       typed = "			Regular expression"
     elseif (type=='&type=fuzzy') then
       typed = "			Fuzzy search"
     elseif (type=='&type=substring') then
       typed = "			Word(s)"
     end
     wr(target,"Type of search is: "..typed)
     
      fyear = gsub(fromyear, '&from_year','')
      tyear = gsub(toyear, '&to_year','')
     wr(target, "Bot searches from the year:		"..fyear.."  until  "..tyear)
     wr(target,'')
     wr(target,"――――――――――――――――――――――――――――――――――――――――――――――――――――――――") 
end


send = " HTTP/1.1"..strchar(13, 10).."Host: us.imdb.com"..strchar(13, 10).."Connection: Close"..strchar(13, 10)..
       "User-Agent: Mozilla/4.0 (blah blah blah whatever blah)"..strchar(13, 10)..strchar(13, 10)

function findNews(target,find)
wr(target,"_____________")
wr(target," Find something!")
wr(target,"―――――――――――――")
wr(target,"Results for: "..find)
wr(target,"――――――――――――――――――――――――――――――――――――――――――――――――――――――――")

file = ""..find..".txt"
if (openfile("imdb/"..file,"r")==nil) then
  local line
  local socket, err = connect("www.us.imdb.com",80) 
  writedonce=0
  tob=nil
    if not err then 
      socket:timeout(2) 
      err = socket:send("GET http://us.imdb.com/Tfuzzy?type=fuzzy&...rono&title="..find..send)
        if not err then 
          writeto("imdb/"..find..".txt") 
          while not(line == "</HTML>") do 
          line, err = socket:receive("*l") 
           if err then break end
           s,e = strfind(line,"<OL><LI><A HREF=")
           if (s~=nil) then tob = strip(line,34) end
           s,e = strfind(line,"<LI><A HREF=") 
           if (s~=nil) then tob = strip(line,30) end   
           if (tob~=nil) then   
           writedonce=1   
           write(" "..tob..strchar(13)..strchar(10)) 
           tob=nil
           end
        end 
        writeto() 
      end 
    end 
    socket:close() 
end

if (writedonce==1 or openfile("imdb/"..file,"r")~=nil) then
--if (checkfile(file) == 1) then
  readfile(target,file)
  readfile(target,"endresult.txt")
--end
end

end
 

function strip(tob,num) 
tob = strsub(tob,num)
tob = gsub(tob, '</A>','') 
tob = gsub(tob, '<I>','') 
tob = gsub(tob, '<BR>','') 
tob = gsub(tob, '</I>','') 
tob = gsub(tob, '</LI>','') 
tob = gsub(tob, '<SMALL>','') 
tob = gsub(tob, '</SMALL>','') 
tob = gsub(tob, '&#[i];','') 
tob = gsub(tob, '<B>','')
tob = gsub(tob, '</B>','')
tob = gsub(tob, '</TD>','')
tob = gsub(tob, '</B></TD>','')
tob = gsub(tob, '</A></TD>','')

for i = 160, 255 do
n=stripchar(i)
tob = gsub(tob, n,'')
end

return tob 
end

function stripchar(num)
n = '&#'..num..';'
return n
end

function headpm(target)
wr(target,"_________________")
wr(target,"IMDb Top 15 Movies!")
wr(target,"―――――――――――――――――")
wr(target,"Rank	was	Title (YEAR)")
wr(target,"――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
end


function getNews1() 
local line
local socket, err = connect("www.us.imdb.com",80)
  if not err then 
    socket:timeout(2) 
    err = socket:send("GET http://www.us.imdb.com/Charts/top-titles-week.html"..send)
      if not err then 
        writeto("imdb/top15.txt") 
        while not(line == "</HTML>") do 
        line, err = socket:receive("*l") 
        s,e = strfind(line,"ALIGN=CENTER><B>") 
        if (s~=nil) then tob = strip(line,33)end 
        o,p = strfind(line,"ALIGN=CENTER>")
        if (o~=nil) then toc = strip(line,30)end

        c,v = strfind(line,"/Title?") 
        if (c~=nil) then

        url = strsub(line,c,c+13)

	top = strip(line,38)
          if strfind(top,'?">') then
            top = strip(line,41)           
          else
            top = strip(line,48)          
          end
        end 

        if (tob~=nil) and (toc~=nil) and (top~=nil) then
          url =  "http://www.us.imdb.com"..url

  write(" "..tob.."	"..toc.."	[ "..url.." ]	"..top..strchar(13)..strchar(10))                                      
        
          tob=nil
          toc=nil
          top=nil
        end
      end 
      writeto() 
    end 
  end 
  socket:close() 
end 

function checkfile(file)
 readfrom ("imdb/"..file)
 n=1 
while 1 do
     local line = read()     
    e,g = strfind(line,"rating")
    if (e ~= nil) then
      n = 1 
    else
      n = 0
      break
    end
    return n 
end
  readfrom() 

end

function readfile(target,file)
  readfrom("imdb/"..file)
  while 1 do
    local line = read()     
    if (line ~= nil) then
      wr(target,line)
    else
      break
    end
  end
  readfrom()
end

CrazyGuy

This is a LUA 4 script. It is better off with a complete re-write than a conversion  ::)

dodgeviper

So please rewrite the script with some added features...
i will be grateful to you..
Posted on: 14 November 2006, 06:27:08
So nobody can convert the IMDB script to 5.1 or write it again.....
it sorts of breaks my heart

CrazyGuy

Have you tried yourself ? Or searched for 1  ???
Maybe there's other reasons why people haven't done it (yet), like other scripts to work on  ::)
Posted on: 15 November 2006, 20:38:05
well, done a little searching myself
Check this thread plz

http://forum.ptokax.org/index.php?topic=6496#msg63873

Same subject, so it can be further discussed there :)

SMF spam blocked by CleanTalk