Public feed #603203

Untitled

public text v1 · immutable
Raw Edit
·published 2007-07-04 16:29 UTC
rendered paste body
set moviever "0.01b"

# Use: .movies help   - Show brief help.
#      .movies now    - Now playing.
#      .movies week   - Opening this week.
#      .movies soon   - Coming soon.
#
#
set moviechans "#sith"
set moviequiet "#sith"
set movietimeout "30000"
package require http
bind pub - .movies proc:movies
bind msg - .movies proc:msgmovies

proc proc:msgmovies {nick uhost hand text} {
	if {![onchan $nick]} {return}
	proc:movies $nick $uhost $hand privmsg $text
	return
}

proc proc:movies {nick uhost hand chan text} {
	set command [lindex [split $text] 0]
	if {([lsearch -exact $::moviechans $chan] == -1) && ($chan != "privmsg")} {return}
	if {([lsearch -exact $::moviequiet $chan] != -1) || ($chan == "privmsg")} {set chan $nick}
	set regexm "";set moviehead "";set moviedata "";set movienames ""
	if {$command == "" || $command == "now"} {
		set regexm {<h2>Now Playing</h2>.*?<ul>(.*?)</ul>}
		set moviehead "Movies Now Playing"
	} elseif {$command == "week"} {
		set regexm {<h3>Opening This Week</h3>.*?<ul>(.*?)</ul>}
		set moviehead "Movies Opening This Week"
	} elseif {$command == "soon"} {
		set regexm {<h3>Coming Soon</h3>.*?<ul>(.*?)</ul>}
		set moviehead "Movies Coming Soon"
	} else {
		puthelp "PRIVMSG $nick :Usage: \002.movies now\002 | \002.movies week\002 | \002.movies soon\002 to show movies now playing, opening this week or coming soon."
		return
	}
	set movieurl "http://www.filmspot.com"
	catch {set page [::http::geturl $movieurl -timeout $::movietimeout]} error
	if {[string match -nocase "*couldn't open socket*" $error]} {
		puthelp "PRIVMSG $chan :Error: couldn't connect to filmspot.com..Try again later."
		return
	}
	if { [::http::status $page] == "timeout" } {
		puthelp "PRIVMSG $chan :Error: Connection to filmspot.com timed out..Try again later."
		return
	}
	set html [::http::data $page]
	::http::cleanup $page
	if {[regexp $regexm $html match moviedata]} {
		regsub -all {<a href.*?>} $moviedata {} moviedata
		regsub -all {</a>} $moviedata {} moviedata
		set movienames [regexp -all -inline {<li>(.*?)</li>} $moviedata]
		regsub -all {<li>.*?</li>} $movienames {} movienames
		puthelp "PRIVMSG $chan :\0038$moviehead\:\003"
		set m 0
		foreach name $movienames {
			if {$name != ""} {
				incr m
				puthelp "PRIVMSG $chan :\00311$m)\003\00310 $name\003"
			}
		}
		puthelp "PRIVMSG $chan :\00314\[End of $moviehead\]\003"
	} else {
		puthelp "PRIVMSG $nick :No movie data found."
	}
}