All pastes #972913 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-04-05 20:30 UTC
rendered paste body
### YouTube Searching script. v0.1
### Made by Mookie		
### Contact me at Efnet for more information or suggestions
### Make sure you load the http.tcl file

### Settings ###

set youtube(timeout) "600000"		;# Youtube geturl timeout. (better leave this default)
set youtube(results) "5"		;# Results to display
set youtube(trigger) "!youtube"	;# Search trigger

#########################################################
## Don't edit below unless you know what you're doing. ##
#########################################################


bind msg - $::youtube(trigger) youtube

proc youtube {nick uhost hand arg} {
	global youtube
	if {$arg == ""} { putmsg $nick "Please use: $::youtube(trigger) KEYWORD"; return }
	set form [http::formatQuery search_query $arg search search]
	set tok [http::geturl http://youtube.com/results?$form -timeout $::youtube(timeout)]
	set data [http::data $tok]
	regsub -all {<b>|</b>} $data {} data
	http::cleanup $tok
	set a "0"
	while {[regexp -- {<a class="newvtitlelink" href="(.*?)" rel="nofollow" onclick=".*?">(.*?)</a><br/>(.*)$} $data -> url title data]} {
		if {$a == $::youtube(results)} { break }
		regexp -nocase {<span id=".*?">\n(.*?)</span>} $data -> info
		set info [string trim $info]
		putmsg $nick "\[Title: $title Link:http://youtube.com$url Description:$info\]"
		incr a
	}
	if {![info exists title]} { putmsg $nick "Nothing found for $arg" }
}