Posted to tcl by Surmaelk at Tue Feb 18 21:24:44 GMT 2020view raw
- ErrorCode:
- Tcl error [m00nie::movie::search]: invalid bareword "lt"
- in expression " $i < 5 ";
- should be "$lt" or "{lt}" or "lt(...)" or ...
- From:
- proc getinfo { url } {
- for { set i 1 } { $i <= 5 } { incr i } { set rawpage [::http::data [::http::geturl "$url" -timeout 5000]] if {[string length rawpage] > 0} { break }
- }
- #########################################################################################
- # Name m00nie::movie
- # Description Uses omdbapi to grab info about a film title then spam it into the chan
- #
- # Version 1.0 - Initial release
- # Website https://www.m00nie.com
- # Notes Create ypu own API keys here: http://www.omdbapi.com
- # requires .chanset #chan +movie
- #########################################################################################
- namespace eval m00nie {
- namespace eval movie {
- package require json
- bind pub - !movie m00nie::movie::search
- # Uncomment bind below to also use "more traditional" !imdb search
- bind pub - !imdb m00nie::movie::search
- variable version "1.0"
- setudef flag movie
- # Setup your own app and keys at the URL above
- variable key "XXXX"
- proc search {nick uhost hand chan text} {
- if {[channel get $chan movie]} {
- putlog "m00nie::movie::search is running"
- regsub -all {\s+} $text "%20" text
- set response [getinfo "http://www.omdbapi.com/?t=$text&apikey=$m00nie::movie::key"]
- #set response [dict get [json::json2dict $response]]
- foreach var { Title Year Rated Released Runtime Genre Actors Plot Metascore imdbRating imdbID } {
- set $var [dict get $response $var]
- }
- set imdburl "http://www.imdb.com/title/$imdbID/"
- puthelp "PRIVMSG $chan :\002$Title ($Year)\002 $Rated \002|\002 $Runtime \002|\002 $Genre \002|\002 $Released"
- puthelp "PRIVMSG $chan :\002Cast:\002 $Actors"
- puthelp "PRIVMSG $chan :\002Plot:\002 $Plot"
- puthelp "PRIVMSG $chan :\002Metascore:\002 $Metascore, \002IMDB Rating:\002 $imdbRating"
- puthelp "PRIVMSG $chan :$imdburl"
- }
- }
- proc getinfo { url } {
- for { set i 1 } { $i < 5 } { incr i } { set rawpage [::http::data [::http::geturl "$url" -timeout 5000]] if {[string length rawpage] > 0} { break }
- }
- putlog "m00nie::movie::getinfo Rawpage length is: [string length $rawpage]"
- if {[string length $rawpage] == 0} { error "omdbapi returned ZERO no data :( or we couldnt connect properly" }
- set ids [dict get [json::json2dict $rawpage]]
- putlog "m00nie::movie::getinfo IDS are $ids"
- return $ids
- }
- }
- }
- putlog "m00nie::movie $m00nie::movie::version loaded"