IMDB

By Gecko321 on Jun 17, 2012

Searches IMDB for a movie
Shows Top10 Movies that are in theaters and on MovieMeter.
Show what is out in theaters now and what is coming out next week
Also shows the Top10 Stars on StarMeter.
Commands:

!Top10
!MovieMeter
!StarMeter
!ComingSoon
!OutNow
!IMDB <movie/show>
imdb.com tt<movie #>

bind pub - !Top10 Top10
bind pub - !MovieMeter MovieMeter
bind pub - !StarMeter StarMeter
bind pub - !ComingSoon ComingSoon
bind pub - !OutNow OutNow
bind pub - !IMDB IMDBSearch
bind pubm - "% *imdb.com*" IMDB

proc Top10 {nick host hand chan arg} {
  package require http

  set url "http://www.imdb.com/chart/"
  set page [http::data [http::geturl $url]]

  putserv "PRIVMSG $chan :IMDB Top 10 Box Office"

  while {[regexp -line {<a  href="/title[^>]*>(.*?)<\/a>.[\((0-9)\)]+} $page => title year]} {

    regsub -line {<a  href="/title[^>]*>(.*?)<\/a>.([\(0-9\)]+)} $page "" page
    regsub -all {(&#x27;)} $title "'" title
    regexp -line {<b>(.*?)<\/b>} $page b rank
    regsub -line {<b>(.*?)<\/b>} $page "" page
    regexp {<td style="text-align: right; padding-right: 20px;">.*?(\$.*?M)} $page => dollar
    regsub {<td style="text-align: right; padding-right: 20px;">.*?(\$.*?M)} $page "" page
    if { $rank < 10} { set rank "0$rank" }
    putserv "PRIVMSG $chan :$rank. $title $year [string repeat - [expr { 50 - [string length "$rank. $title $year"] }]] ($dollar)"
  }
}

proc MovieMeter {nick host hand chan arg} {
  package require http

  set url "http://www.imdb.com/chart/"
  set page [http::data [http::geturl $url]]

  putserv "PRIVMSG $chan :MovieMeter Top 10"
  set r 0
  while {[regexp -line {<td><a href="/title[^>]*>(.*?)<\/a>.([\(0-9\)]+)} $page => title year]} {
    incr r
    regsub -line {<td><a href="/title[^>]*>(.*?)<\/a>.([\(0-9\)]+)} $page "" page
    regsub -all {(&#x27;)} $title "'" title
    regsub -all {(&#x22;)} $title "\"" title
    if { $r < 10} { set rank "0$r"
    } else { set rank $r }
    putserv "PRIVMSG $chan :$rank. $title $year"
  }
}

proc StarMeter {nick host hand chan arg} {
  package require http

  set url "http://www.imdb.com/chart/"
  set page [http::data [http::geturl $url]]

  putserv "PRIVMSG $chan :StarMeter Top 10"
  set r 0

  while {[regexp -line {<td><a href="/name/[^>]*>(.*?)<\/a>} $page  => actor]} {
    incr r
    regsub -line {<td><a href="/name/[^>]*>(.*?)<\/a>} $page "" page
    if { $r < 10} { set rank "0$r"
    } else { set rank $r }
    putserv "PRIVMSG $chan :$rank. $actor"
  }
}

proc ComingSoon {nick host hand chan arg} {
  package require http

  set url "http://www.imdb.com/movies-coming-soon/"
  set page [http::data [http::geturl $url]]

  regexp {<h4 class="[^>]*>(.*?)<h4 class="} $page => date
  if {![info exists date]} { set date $page }  
  regexp -line {<a name="[^>]*>([A-Za-z 0-9]+)} $date => day
  regexp {itemprop='url'>.*?.([\(0-9\)]+)<\/a><\/h4>} $date => year
  putserv "PRIVMSG $chan :Movies coming out the week of $day, [string range $year 1 4]"

  while {[regexp  -line {itemprop='url'>([A-Za-z0-9].*?)[\(0-9\)]+<\/a>.*?<\/h4>} $date => movie year]} {
    regsub -line {itemprop='url'>([A-Za-z0-9].*?)[\(0-9\)]+<\/a>.*?<\/h4>} $date "" date
    regexp {href="/title/([t]+[0-9]+)/#lb} $date => title
    regsub {href="/title/([t]+[0-9]+)/#lb} $date "" date
    if {[info exists title]} { set trailer "Trailer: http://www.imdb.com/title/$title/#lb"
    } else { set trailer "" }
    putserv "PRIVMSG $chan :-[string trim $movie] [string repeat - [expr { 50 - [string length [string trim $movie]] }]] $trailer"
  }
}

proc OutNow {nick host hand chan arg} {
  package require http

  set url "http://www.imdb.com/movies-in-theaters/"
  set page [http::data [http::geturl $url]]

  regexp {(<h3>(.*?)<h3>)} $page => date
  regexp -line {<h3>Opening This Week - (.*?)&nbsp;<\/h3>} $date => day
  regexp {itemprop='url'>.*?.([\(0-9\)]+)<\/a><\/h4>} $date => year
  putserv "PRIVMSG $chan :Movie out the week of $day, [string range $year 1 4]"

  while {[regexp  -line {itemprop='url'>([A-Za-z0-9].*?)[\(0-9\)]+<\/a>.*?<\/h4>} $date => movie year]} {
    regsub -line {itemprop='url'>([A-Za-z0-9].*?)[\(0-9\)]+<\/a>.*?<\/h4>} $date "" date
    regexp {href="/title/([t]+[0-9]+)/#lb} $date => title
    regsub {href="/title/([t]+[0-9]+)/#lb} $date "" date
    if {[info exists title]} { set trailer "Trailer: http://www.imdb.com/title/$title/#lb"
    } else { set trailer "" }
    putserv "PRIVMSG $chan :-[string trim $movie] [string repeat - [expr { 50 - [string length [string trim $movie]] }]] $trailer"
  }
}

proc IMDB {nick host hand chan arg} {

  package require http
  regexp {([t]+[0-9]+)} $arg arg
  set url "http://www.imdb.com/title/$arg/"
  set page [http::data [http::geturl $url]]
  regexp {data-video="([vi]+[0-9]+)} $page => vid
  regexp {<title>(.*?)<\/title>} $page => title
  regsub { - IMDb} $title "" title
  if {[info exists vid]} {
    putquick "PRIVMSG $chan :\00307TRAILER:\003 $title :: IMDB ::\00306 http://www.imdb.com/video/imdb/$vid " 
  }
}
proc IMDBSearch {nick host hand chan arg} {
  package require http
  set arg [string map { " " "+" } $arg]  
  set url "http://www.imdb.com/find?q=$arg&s=all"
  set page [http::data [http::geturl $url]]

  regexp {(<p>.*?<\/p>)} $page => movie
  regexp {r><a href=\"\/title\/([a-z0-9]+).*?>(.*?)<\/a>.*?\(([0-9]+)\)} $movie => title name year

  if {[info exists title]} {
    set url "http://www.imdb.com/title/$title/"
    set page2 [http::data [http::geturl $url]]

    regexp {director\".*?>(.*?)<\/a>} $page2 => dir
    regexp {datePublished\".*?>(.*?)</time} $page2 => rel
    regexp {ratingValue">(.*?)</span>} $page2 => rating
    regexp {prop="description">(.*?)<\/p>} $page2 => desc
    regsub {(&#x27;)} $desc "" desc
    regexp {"infobar">.*?="15"> ([0-9]+) min(.*?)<span c} $page2 => length infobar
    regsub -all {(<.*?>)} $infobar "" genre
    set genre [string map {&nbsp; "" - "" " " ""} $genre]
    regexp {Taglines:<\/h4>(.*?)<span class=} $page2 => tagline

    putserv "PRIVMSG $chan :$name ($year) Rating: [bar $rating] $rating/10"
    putserv "PRIVMSG $chan :$length min ([string trim $genre])"
    putserv "PRIVMSG $chan :Tagline: [string trim $tagline]"
    putserv "PRIVMSG $chan :[string trim $desc]"
    putserv "PRIVMSG $chan :Link: http://imdb.com/title/$title/"
  } else { puts "No Movie Found." }
}

proc bar {float} {
  set stars [format "%1.0f" $float];
  return "\[[string repeat "*" $stars][string repeat "-" [expr 10-$stars]]\]"
}
putlog "IMDB v1.0"

Comments

Sign in to comment.
pei   -  Nov 27, 2012

Using eggdrop 1.8
Using tcl 8.5.13-1

 Respond  
pei   -  Nov 27, 2012

[06:32:33] Tcl error [IMDBSearch]: can't read "infobar": no such variable

 Respond  
Fuzion   -  Jul 01, 2012

great work once again :) keep it up

s-c-o-o-t  -  25 days ago

This script don't work. At all waste of space :)))

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.