this tcl doesent work wen i type
!yt Video_here
Code: Select all
bind pub -|- !yt yt_search
###
### youtube getlink v 0.1
###
### just a simple script that fetches the first
### result from a youtube search, giving you
### the link, title and description for the primary
### result
###
### nothing can be set here
### if you know tcl please edit to fit your need
### grtz hwk
### contact me at: lowraider1@gmail.com
package require http
proc yt_search {nick uhost hand chan args} {
regsub -nocase -all " " $args "+" yt(squery)
set yt(surl) "http://youtube.com/results?search_query=$yt(squery)&search_type="
http::config -useragent mozilla
set urltok [http::geturl $yt(surl) -timeout 20000]
set yt(rpage) [http::data $urltok]
http::cleanup $urltok
regsub -nocase -all (<b>|</b>|\t|<i>|</i>) $yt(rpage) "" rpage
regexp -line -- {<div class="vlshortTitle">\n(.*)\n</div>} $rpage -> yt(infos)
regexp {<a href="(.*)" title} $yt(infos) -> yt(link)
regexp {>(.*)</a>} $yt(infos) -> yt(title)
regexp -line -- {<div class="vldesc">\n(.*)\n</div>\n</div>} $rpage -> yt(desc)
if {[string match -nocase "*No Videos found*" $rpage] || ![info exists yt(title)]} {puthelp "privmsg $chan :Nothing found"} else {
puthelp "privmsg $chan :LINK: http://youtube.com$yt(link) | Title: $yt(title) | Description: $yt(desc)"}
}
putlog "youtube getlink v 0.1 by hwk loaded"