Advertisement
Guest User

Untitled

a guest
Jan 17th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.28 KB | None | 0 0
  1. ###############################################################################
  2. ## This iMDB.tcl requires Eggdrop1.6.0 or higher ##
  3. ## (c) 2003 by B0unTy ##
  4. ## ##
  5. ## changed by gr11x ##
  6. ## 17.01.2013 ##
  7. ## * Fixed search request url and search page identification ##
  8. ## ##
  9. ## changed by username and caesar ##
  10. ## 19.03.2012 ##
  11. ## * some random code trimming by username and caesar ##
  12. ## ##
  13. ## changed by username ##
  14. ## 16.03.2012 ##
  15. ## * changed the anti-flood protection, it was malfunctioning and it's now ##
  16. ## replaced with a new throttle control. ##
  17. ## ##
  18. ## changed by spithash ##
  19. ## 30.09.2011 ##
  20. ## * Fixed rating cause imdb's website has changed a little bit ##
  21. ## * Changed the default theme of 'set announce(IMDBIRC)' to my needs. ##
  22. ## Don't get nasty if it doesn't look like the old/default one. ##
  23. ## You can change it back to how you had it using your previous version. ##
  24. ## ##
  25. ## changed by znuff ##
  26. ## 23.08.2011 ##
  27. ## * Fixed parse of multiple cookies (release date, rating, rbar, votes, ##
  28. ## title, runtime, awards, comments, mpaa, cert) ##
  29. ## * Fixed color output for rbar ##
  30. ## * Set output to UTF-8 by default ##
  31. ## * Added a new cookie - bullet separator (%bull) ##
  32. ## * Runtime cookie now includes the prefix "min" ##
  33. ## * Changed default search url to akas.* to bypass the stupid localization ##
  34. ## of the title ##
  35. ## * Grabbing user comments makes another request to IMdb! ##
  36. ## * What I didn't fix: company, cast_multiline, cast_ine, screens - they ##
  37. ## do produce output, but not the desired one, and I have no intention ##
  38. ## to fix ##
  39. ## ##
  40. ## changed by username ##
  41. ## 19.10.2010 ##
  42. ## *fixed page parsing errors ##
  43. ## ##
  44. ## changed by OV2 ##
  45. ## 05.01.2010 ##
  46. ## *fixed remaining bugs with imdb changes ##
  47. ## ##
  48. ## 02.01.2010 ##
  49. ## *modified for imdb page changes ##
  50. ## ##
  51. ## 16.09.2008 ##
  52. ## *modified for new imdb page ##
  53. ## ##
  54. ## 25.05.2008 ##
  55. ## *plot works again ##
  56. ## ##
  57. ## 19.05.2008 ##
  58. ## *fixed the non-working cookies (cert, soundmix ...) ##
  59. ## * "|" characters in cookies are displayed again ##
  60. ## ##
  61. ## 21.09.2007 ##
  62. ## *multiline color/underline/bold were broken ##
  63. ## +added single-line cast (%castline) ##
  64. ## +added the remaining information from imdb (color, cert, etc...) ##
  65. ## ##
  66. ## 17.07.2007 ##
  67. ## *fix for the exact title matching ##
  68. ## *exact name matches are no longer confused with exact title matches ##
  69. ## ##
  70. ## 27.06.2007 ##
  71. ## *works with new imdb search page ##
  72. ## *%uline works again ##
  73. ## ##
  74. ## 09.04.2007: ##
  75. ## *fixed director/s writer/s ##
  76. ## +added support for plot keywords ##
  77. ## +added support for user comment line ##
  78. ## ##
  79. ## 28.02.2007: ##
  80. ## *ratings work again ##
  81. ## *director and writing credits work again ##
  82. ## ##
  83. ## 25.02.2007: ##
  84. ## *fixed some bugs of the previous changes (thanks to rosc2112) ##
  85. ## ##
  86. ## 24.02.2007: ##
  87. ## *bold/underline/color in front of the multiline cast will now be ##
  88. ## applied to each of the cast lines ##
  89. ## *the | character is now used to declare sections in the announce line ##
  90. ## if any variable in a section is not found on the imdb page, the ##
  91. ## corresponding section will not be displayed in the output ##
  92. ## (see the default announce line for an example) ##
  93. ## ##
  94. ## 22.02.2007: ##
  95. ## *incorporated some code from rosc2112's version ##
  96. ## *some small fixes ##
  97. ## ##
  98. ## 20.02.2007: ##
  99. ## *changed regexp queries to accomodate the new imdb layout ##
  100. ## *cleaned up the unneccesary post-regexp code ##
  101. ## ##
  102. ## 14.05.2006: ##
  103. ## *fixed plot outline not showing completely if it included links ##
  104. ## (thanks to darkwing for finding the bug) ##
  105. ## +added support for awards (thanks to rosc2112) ##
  106. ## +added support for the cast list (be careful with the limit) ##
  107. ## +added support for writing credits ##
  108. ## ##
  109. ## 21.01.2006: ##
  110. ## *fixed problem with irregular search-result pages from imdb ##
  111. ## ##
  112. ## 31.08.2005: ##
  113. ## *changed search result priority again: ##
  114. ## 1. popular match where the title=search string ##
  115. ## 2. exact matches ##
  116. ## 3. first title on page ##
  117. ## *fixed missig warn_msg var ##
  118. ## ##
  119. ## until 24.06.2005: ##
  120. ## *works with new IMDB ##
  121. ## *works with (hopefully) all search results (popular/exact/partial) ##
  122. ## +added timeouts (20secs) ##
  123. ## +added bottom 100 support ##
  124. ## +added rating bar from chilla's imdb-script ##
  125. ## +added flood control ##
  126. ## *small speedup (if your output does not include %screens or %budget ##
  127. ## *changed proc name to improve compatibility with other scripts ##
  128. ## *changed search result priority to {exact->first displayed} ##
  129. ## ##
  130. ###############################################################################
  131. ## ##
  132. ## INSTALL: ##
  133. ## ======== ##
  134. ## 1- Copy iMDB.tcl in your dir scripts/ ##
  135. ## 2- Add iMDB.tcl in your eggdrop.conf: ##
  136. ## source scripts/imdb.tcl ##
  137. ## ##
  138. ## For each channel you want users to use !imdb cmd ##
  139. ## Just type in partyline: .chanset #channel +imdb ##
  140. ## ##
  141. ###############################################################################
  142. # COOKIES ARE :
  143. # =============
  144. # TITLE = %title | BOLD = %bold
  145. # URL = %url | UNDERLINE = %uline
  146. # DIRECTOR = %name | COLORS = %color#,#
  147. # GENRE = %genre | NEW LINE = \n
  148. # PLOT OUTLINE = %plot |-----------------------------
  149. # RATING = %rating | !! to reset color code !!
  150. # RATING_BAR = %rbar | !! use %color w/o args !!
  151. # VOTES = %votes |
  152. # RUNTIME = %time (incl. "min") | "|" declares a section
  153. # AWARDS = %awards | if any cookie in a section
  154. # BUDGET = %budget | is empty the whole section
  155. # SCREENS = %screens | is removed from the output
  156. # TAGLINE = %tagline | (end section with "|")
  157. # MPAA = %mpaa |
  158. # COUNTRY = %country |
  159. # LANGUAGE = %language |
  160. # SOUND MIX = %soundmix |
  161. # TOP 250 = %top250 |
  162. # CAST LINES = %castmline |
  163. # CAST SNGLELINE = %castline |
  164. # WRITING CREDITS = %wcredits |
  165. # PLOT KEYWORDS = %keywords |
  166. # COMMENT LINE = %comment |
  167. # RELEASE DATE = %reldate |
  168. # MOVIE COLOR = %mcolor |
  169. # ASPECT RATIO = %aspect |
  170. # CERTIFICATION = %cert |
  171. # LOCATIONS = %locations |
  172. # COMPANY = %company |
  173. #
  174. # + 19.10.2010
  175. # Also Known As = %aka
  176. # + 23.8.2011
  177. # BULLET (separator)= %bull
  178. #
  179. # RANDOMIZING OUTPUT :
  180. # ====================
  181. # Exemple:
  182. # set random(IMDBIRC-0) "IMDB info for %bold%title%bold Directed by %name"
  183. # set random(IMDBIRC-1) "IMDB info for %title Directed by %bold%name%bold"
  184. # set random(IMDBIRC-2) "IMDB info for %title Directed by %name"
  185. # TYPE --------^ ^
  186. # ID --------^
  187. #
  188. # set announce(IMDBIRC) "random 3"
  189. # TYPE ---------^ ^ ^
  190. # RANDOM ----------^ ^
  191. # # OF IDS ---------^
  192. #
  193. # exemple random announces:
  194. # set announce(IMDBIRC) "random 3"
  195. # set random(IMDBIRC-0) "IMDB info for %bold%title%bold Directed by %name -> rated %uline%rating%uline (%votes votes) - genre: %genre - runtime: %time mins >> URL: %uline%url%uline >> Budget: %budget >> Screens: (USA) %screens"
  196. # set random(IMDBIRC-1) "TITLE: %bold%title%bold - DIRECTOR: %name - RATE: %rating by %votes users - GENRE: %genre - RUNTIME: %time mins - URL: %url - BUDGET: %budget - SCREENS: (USA) %screens"
  197. set announce(IMDBIRC) "%bold%title%bold %color4-%color %url %color4-%color %boldDirected by:%bold %name %color4-%color %boldGenre:%bold %genre %color4-%color %boldRelease Date:%bold %reldate %color4-%color %boldBudget:%bold %budget %color4-%color %boldScreens:%bold %screens %color4-%color %boldRating:%bold%color7 %rating/10 %rbar %color14(%color3 %votes votes\%color14 )\n%boldPlot:%bold %plot%bold %color4-%color %boldRuntime:%bold %time."
  198. # example normal announce:
  199. # set announce(IMDBIRC) "%bold%title%bold - %url\n|Rating: %rating (%votes votes) %rbar| |%top250|\n|%plot|"
  200. # set announce(IMDBIRC) "%bold%title%bold |\[%time mins - %mcolor\]| - %url\n|Genre: %genre|\n|Tagline: %tagline|\n|Synopsis: %plot|\n|Rating: %rating (%votes votes) %rbar| |%color3%top250%color|\n|Awards: %awards|"
  201.  
  202. #set announce(IMDBIRC) "%bold%title%bold - %url\n|%boldGenre:%bold %genre|\n|Plot Keywords: %keywords|\n|Tagline: %tagline|\n|Synopsis: %plot|\n|Rating: %rating (%votes votes) %rbar| |%color3%top250%color|\n|Comment: %comment|\n|Awards: %awards|\n|Runtime: %time mins.|"
  203.  
  204. # set default announce format
  205. #set announce(IMDBIRC) "
  206. #%bold%title%bold (%aka)\n
  207. #|%boldTagline:%bold %tagline %bold\n|
  208. #|%boldURL:%bold %url| |%bull %boldGenre:%bold %genre\n|
  209. #|%boldRelease date:%bold %reldate| |%bull %boldRating:%bold %rating (%votes votes)| |%bull %boldRuntime:%bold %time|\n
  210. #"
  211.  
  212. #trigger command in channel
  213. set trigger "!imdb"
  214.  
  215. #rating bar color
  216. #bracket
  217. set barcol1 "14"
  218. #stars
  219. set barcol2 "7"
  220. #cast count to return on multiline and single line (0 means no limit)
  221. set cast_linelimit "5"
  222.  
  223. #http connection timeout (milliseconds)
  224. set imdb_timeout "25000"
  225.  
  226. # Delay between command for each channel.
  227. set delay 20
  228.  
  229. # for a channel !imdb request
  230. # set to 1 = all results will be sent publicly to the channel
  231. # set to 0 = all results will be sent as private notice
  232. set pub_or_not 1
  233.  
  234. # use or not the imdb debugger (1=enable debug 0=disable debug)
  235. set IMDB_DEBUG 0
  236.  
  237. # set IMDB_ALTERNATIVE 0 = use the internal tcl http 2.3 package
  238. # set IMDB_ALTERNATIVE 1 = use the external curl 6.0+
  239. set IMDB_ALTERNATIVE 0
  240.  
  241. # set here the location path where find curl 6.0+
  242. set binary(CURL) "/usr/bin/curl"
  243. # note for windrop: use normal slashes, e.g. C:/path/to/curl.exe
  244.  
  245. #################################################################
  246. # DO NOT MODIFY BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING! #
  247. #################################################################
  248. if { $IMDB_ALTERNATIVE == 0 } { package require http 2.3 }
  249. setudef flag imdb
  250.  
  251. bind pub -|- $trigger imdb_proc
  252.  
  253. set instance 0
  254. set warn_msg 0
  255.  
  256. proc htmlcodes {tempfile} {
  257. # set mapfile [string map {& & ' ' ' ' [ ( \ / ] ) { ( } ) " " ? ? ? ? © © « « ­ ­ ® ® ? ? ? ? } $tempfile]
  258. # set mapfile [string map {? ? · · ^(1) ^(1) » » 1/4 1/4 1/2 1/2 3/4 3/4 A` A` A' A' A^ A^ } $mapfile]
  259. # set mapfile [string map {A~ A~ A" A" A* A* ? ? C, C, E` E` E' E' E^ E^ E" E" I` I` I' I' I^ I^ I" I" ? ? N~ N~ O` O` O' O' O^ O^ O~ O~ O" O" } $mapfile]
  260. # set mapfile [string map {? ? ? ? U` U` U' U' U^ U^ U" U" Y' Y' ? ? ? ? a` a` a' a' a^ a^ a~ a~ a" a" a* a* ? ? c, c, e` e` e' e' e^ e^ } $mapfile]
  261. # set mapfile [string map {e" e" i` i` i' i' i^ i^ i" i" ? ? n~ n~ o` o` o' o' o^ o^ o~ o~ o" o" ? ? ? ? u` u` u' u' u^ u^ u" u" y' y' ? ? } $mapfile]
  262. set mapfile [string map {  "" & "&" " \"} $tempfile]
  263. return $mapfile
  264. }
  265.  
  266. proc replacevar {strin what withwhat} {
  267. set output $strin
  268. set replacement $withwhat
  269. set cutpos 0
  270. while { [string first $what $output] != -1 } {
  271. set cutstart [expr [string first $what $output] - 1]
  272. set cutstop [expr $cutstart + [string length $what] + 1]
  273. set output [string range $output 0 $cutstart]$replacement[string range $output $cutstop end]
  274. }
  275. return $output
  276. }
  277.  
  278. proc findnth {strin what count} {
  279. set ret 0
  280. for {set x 0} {$x < $count} {incr x} {
  281. set ret [string first $what $strin [expr $ret + 1]]
  282. }
  283. return $ret
  284. }
  285.  
  286. proc imdb_proc { nick uhost handle chan arg } {
  287. global cast_linelimit instance delay imdb_timeout barcol1 barcol2 IMDB_DEBUG pub_or_not announce random warn_msg trigger binary IMDB_ALTERNATIVE
  288. variable imdb
  289. # channel_check permission
  290. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG permission_result == $permission_result" }
  291. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG instance == $instance" }
  292. if {![channel get $chan imdb]} { return }
  293. # public or private
  294. if {$pub_or_not == 1 } { set toput "PRIVMSG $chan" } else { set toput "NOTICE $nick" }
  295. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG toput_result == $toput" }
  296. # if no arg passed, show help
  297. if {$arg == ""} {
  298. if { $IMDB_ALTERNATIVE == 0 } { set using "Http 2.3+" } else { set using "Curl 6.0+" }
  299. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG no arg passed, show help" }
  300. puthelp "$toput :IMDb info script \002v30.09.2011\002 using \002$using\002"
  301. puthelp "$toput :\002Syntax: $trigger <movie title>\002 example: $trigger Beautiful Mind"
  302. return
  303. }
  304.  
  305. #flood-control
  306. if {[info exists imdb(lasttime,$chan)] && [expr $imdb(lasttime,$chan) + $delay] > [clock seconds]} {
  307. putserv "NOTICE $nick :You can use only 1 command in $delay seconds. Wait [expr $delay - [expr [clock seconds] - $imdb(lasttime,$chan)]] seconds and try again."
  308. return 0
  309. }
  310.  
  311. # initial search
  312. set imdburl "http://akas.imdb.com"
  313. set imdbsearchurl "http://akas.imdb.com/find?s=tt&exact=true&"
  314. set searchString [string map {\ %20 & %26 , %2C} $arg]
  315. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG searchString: \"$searchString\"" }
  316. if { $IMDB_ALTERNATIVE == 0 } {
  317. set page [::http::config -useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"]
  318. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG ${imdbsearchurl}q=$searchString" }
  319. if [catch {set page [::http::geturl ${imdbsearchurl}q=$searchString -timeout $imdb_timeout]} error] {
  320. puthelp "$toput :Error retrieving URL... try again later."
  321. ::http::Finish $page
  322. return
  323. }
  324. if { [::http::status $page] == "timeout" } {
  325. puthelp "$toput :\002Connection to imdb.com timed out while doing initial search.\002"
  326. ::http::Finish $page
  327. return
  328. }
  329. set html [::http::data $page]
  330. ::http::Finish $page
  331. } else {
  332. catch { exec $binary(CURL) "${imdbsearchurl}q=$searchString" } html
  333. }
  334. #if redirect necessary (search page), find first link and redirect
  335. if { ([regexp {<title>Find - IMDb} $html] == 1) } {
  336. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG redirect 1" }
  337. set ttcode "0000001"
  338. set start "0"
  339. set temp $html
  340.  
  341. #dealing with different search results
  342. set hit 0
  343. if { [regexp -indices {Popular Titles} $temp tstart] } {
  344. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG found popular titles" }
  345. set temp2 [string range $temp [lindex $tstart 1] end]
  346. regexp {1\..*?<a.*?>(.*?)</a>} $temp2 dummy title
  347. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG compare $title == $arg" }
  348. if { [string equal -nocase $title $arg] } {
  349. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG equals - displaying first popular match" }
  350. set temp $temp2
  351. set hit 1
  352. } else {
  353. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG not equal - searching for exact match" }
  354. }
  355.  
  356. }
  357. if { $hit == 0 } {
  358. if { [regexp -indices {Titles \(Exact Matches\)} $temp start] } {
  359. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG displaying exact match" }
  360. } elseif { [regexp -indices {Titles} $temp start] } {
  361. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG no exact match - displaying first title on page" }
  362. } else {
  363. puthelp "$toput :No useful results."
  364. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG no titles results found" }
  365. return
  366. }
  367. set temp [string range $temp [lindex $start 1] end]
  368. }
  369.  
  370. #searching for first ttcode
  371. if [regexp {/title/tt[0-9]+} $temp ttcode] {
  372. set pos [string last / $ttcode] ; incr pos
  373. set ttcode [string range $ttcode $pos end]
  374. }
  375. # for bogus ttcode
  376. if { $ttcode == "0000001" } {
  377. puthelp "$toput :No no no! I can't find that!"
  378. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG bogus ttcode" }
  379. return
  380. }
  381. set newurl "$imdburl/title/$ttcode/"
  382. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG redirect 1 = $newurl" }
  383. # get the page redirected to
  384. unset html
  385. if { $IMDB_ALTERNATIVE == 0 } {
  386. set page [::http::config -useragent "MSIE 6.0"]
  387. set page [::http::geturl $newurl -timeout $imdb_timeout]
  388. if [catch {set page [::http::geturl $newurl -timeout $imdb_timeout]} error] {
  389. puthelp "$toput :Error retrieving URL... try again later."
  390. ::http::Finish $page
  391. return
  392. }
  393. if {[::http::status $page]=="timeout"} {
  394. puthelp "$toput :\002Connection to imdb.com timed out.\002"
  395. ::http::Finish $page
  396. return
  397. }
  398. set html [::http::data $page]
  399. ::http::Finish $page
  400. } else {
  401. catch { exec $binary(CURL) "$newurl" } html
  402. }
  403. # if no redirect necessary (only one match in meta), then go there
  404. } else {
  405. set location ""
  406. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG redirect 0" }
  407. if { $IMDB_ALTERNATIVE == 0 } {
  408. upvar 0 $page oldpage
  409. regexp {title/tt[0-9]+/} $oldpage(meta) location
  410. } else {
  411. set result [catch { exec $binary(CURL) -i "${imdbsearchurl}q=$searchString" } oldpage]
  412. putlog $oldpage
  413. regexp {title/tt[0-9]+/} $oldpage location
  414. }
  415. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG redirect 0 Location == $location" }
  416. set newurl "$imdburl/$location"
  417. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG redirect 0 = $newurl" }
  418. if { $location != "" } {
  419. if { $IMDB_ALTERNATIVE == 0 } {
  420. unset html
  421. set page [::http::config -useragent "MSIE 6.0"]
  422. if [catch {set page [::http::geturl $newurl -timeout $imdb_timeout]} error] {
  423. puthelp "$toput :Error retrieving URL... try again later."
  424. ::http::Finish $page
  425. return
  426. }
  427. if {[::http::status $page]=="timeout"} {
  428. puthelp "$toput :\002Connection to imdb.com timed out.\002"
  429. ::http::Finish $page
  430. return
  431. }
  432. set html [::http::data $page]
  433. ::http::Finish $page
  434. } else {
  435. unset html
  436. catch { exec $binary(CURL) "$newurl" } html
  437. }
  438. } else {
  439. puthelp "$toput :Error in search mechanics - you probably need a newer version."
  440. return
  441. }
  442. }
  443. # grab footer content / user comment
  444. if { $newurl != "" } {
  445. set part2 "_ajax/footer"
  446. set footerurl "$newurl$part2"
  447. if { $IMDB_ALTERNATIVE == 0 } {
  448. set page [::http::config -useragent "MSIE 6.0"]
  449. if [catch {set page [::http::geturl $footerurl -timeout $imdb_timeout]} error] {
  450. puthelp "$toput :Error retrieving URL... try again later."
  451. ::http::Finish $page
  452. return
  453. }
  454. if {[::http::status $page]=="timeout"} {
  455. puthelp "$toput :\002Connection to imdb.com timed out.\002"
  456. ::http::Finish $page
  457. return
  458. }
  459. set html2 [::http::data $page]
  460. ::http::Finish $page
  461. } else {
  462. catch { exec $binary(CURL) "$footerurl" } html2
  463. }
  464. } else {
  465. puthelp "$toput :Error in search mechanics - you probably need a newer version."
  466. return
  467. }
  468.  
  469. # for bogus searches
  470. if {[string length $newurl] == 0} {
  471. puthelp "$toput :No no no! I can't find that!"
  472. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG bogus searches" }
  473. return
  474. }
  475. # decide on output
  476. if { ! [string compare [lindex $announce(IMDBIRC) 0] "random"] && [string is alnum -strict [lindex $announce(IMDBIRC) 1]] == 1 } {
  477. set output $random(IMDBIRC\-[rand [lindex $announce(IMDBIRC) 1]])
  478. } else {
  479. set output $announce(IMDBIRC)
  480. }
  481.  
  482. # collect output
  483. set title "N/A"; set aka "N/A"; set name "N/A"; set genre "N/A"; set tagline "N/A"; set plot "N/A"; set rating "N/A";
  484. set votes "N/A"; set mpaa "N/A"; set runtime "N/A"; set budget "N/A"; set screens "N/A"; set country "N/A"; set language "N/A";
  485. set soundmix "N/A"; set top250 "top/bottom:N/A"; set awards "N/A"; set rating_bar ""; set cast_multiline "N/A"; set wcredits "N/A";
  486. set keywords "N/A"; set comment "N/A"; set reldate "N/A"; set cast_line "N/A"; set movie_color "N/A"; set aspect_ratio "N/A";
  487. set cert "N/A"; set film_locations "N/A"; set company "N/A"
  488.  
  489. ## get title
  490. if [regexp {<title>[^<]+} $html title dummy] {
  491. set pos [expr [string first > $title] +1]
  492. set pos2 [expr [string first ) $title]]
  493. set title [string range $title $pos $pos2]
  494. set title [htmlcodes $title]
  495. }
  496. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG title == $title" }
  497.  
  498. ## get aka
  499. if [regexp {<h4 class="inline">Also Known As:</h4>(.*?)</div>} $html dummy aka] {
  500. regsub -all {<[^\>]*>} $aka {} aka
  501. set aka [string map {"See more" "" \n "" &amp; " & " &raquo; ""} $aka]
  502. set aka [string trim $aka]
  503. set aka [htmlcodes $aka]
  504. }
  505. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG aka == $aka" }
  506.  
  507. ## get director
  508. if [regexp {<h4 class="inline">.*?Director:.*?</h4>(.*?)</div>} $html dummy name] {
  509. regsub -all {\n[ ]*} $name {} name
  510. set name [string map {"&<br/>" "& " "<br/>" ", " "See more" ""} $name]
  511. regsub -all {<[^>]+>} $name {} name
  512. set name [string trim $name]
  513. regsub -all {,$} $name {} name
  514. set name [htmlcodes $name]
  515. }
  516. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG director == $name" }
  517. ## get writing credits
  518. if [regexp {<h4 class="inline">.*?Writers:.*?</h4>(.*?)</div>} $html dummy wcredits] {
  519. regsub -all {\n[ ]*} $wcredits {} wcredits
  520. set wcredits [string map {"See more" "" "<br/>&nbsp;" "" "&<br/>" "& " "&#x26;<br/>" "& " "<br/>" ", " "&raquo;" ""} $wcredits]
  521. regsub -all {<[^>]+>} $wcredits {} wcredits
  522. set wcredits [string trim $wcredits]
  523. regsub -all {,$} $wcredits {} wcredits
  524. set wcredits [htmlcodes $wcredits]
  525. }
  526. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG writer == $wcredits" }
  527. # release date
  528. if {[regexp {<time itemprop="datePublished" .*?>(.*?)</time>} $html dummy reldate]} {
  529. regsub -all {[\n\s]+} $runtime {} runtime
  530. }
  531. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG release date == $reldate" }
  532. ## get genre
  533. if [regexp {<h4 class="inline">Genres:</h4>(.*?)</div>} $html dummy genre] {
  534. set genre [string map {"See more" "" &nbsp; " "} $genre]
  535. regsub -all {<[^\>]*>} $genre {} genre
  536. set genre [string map {"|" "||" } $genre]
  537. set genre [string trim $genre]
  538. regsub {\(.*\)} $genre {} genre
  539. }
  540. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG genre == $genre" }
  541. ## get tagline
  542. if [regexp {<h4 class="inline">Taglines:</h4>(.*?)<} $html dummy tagline] {
  543. set tagline [string map {"See more" "" } $tagline]
  544. regsub -all {<[^\>]*>} $tagline {} tagline
  545. set tagline [string trim $tagline]
  546. set tagline [htmlcodes $tagline]
  547. }
  548. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG tagline == $tagline" }
  549. ## get plot outline
  550. if { [regexp {<h2>Storyline</h2>(.*?)<em .*?>} $html dummy plot] || [regexp {<h5>Plot Summary:</h5>(.*?)</div>} $html dummy plot] } {
  551. set plot [string map {"See more" "" "(view trailer)" "" "full summary" "" "add synopsis" "" "full synopsis (warning! may contain spoilers)" "" "full synopsis" "" " | " ""} $plot]
  552. regsub -all {<[^\>]*>} $plot {} plot
  553. set plot [string trim $plot]
  554. set plot [string range $plot 0 357]
  555. set plot [htmlcodes $plot]
  556. }
  557. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG plot == $plot" }
  558. ## get plot keywords
  559. if [regexp {<h4 class="inline">Plot Keywords:</h4>(.*?)</div>} $html dummy keywords] {
  560. set keywords [string map {"See more" "" \n "" &nbsp; " " &raquo; ""} $keywords]
  561. regsub -all {<[^\>]*>} $keywords {} keywords
  562. set keywords [string map {"|" "||"} $keywords]
  563. set keywords [string trim $keywords]
  564. set keywords [htmlcodes $keywords]
  565. }
  566. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG keywords == $keywords" }
  567. ## get awards
  568. if [regexp {<div class="article highlighted" >(.*?)<span.*?href="awards"} $html awards] {
  569. regsub -all {[\n]} $awards {} awards
  570. set pos [expr [string first "<b>" $awards] +3]
  571. set pos2 [expr [string first "<span" $awards] -1]
  572. set awards [string range $awards $pos $pos2]
  573. set awards [string map {"</b>" " "} $awards]
  574. set awards [htmlcodes $awards]
  575. }
  576. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG awards == $awards" }
  577. ## get comment
  578. if [regexp {<div class="user-comments">.*?</strong>} $html2 comment] {
  579. regsub -all {[\n]} $comment {} comment
  580. set pos [expr [string first "<strong>" $comment] +8]
  581. set pos2 [expr [string first "</strong>" $comment] -9]
  582. set comment [string range $comment $pos $pos2]
  583. set comment [string trim $comment]
  584. set comment [htmlcodes $comment]
  585. }
  586. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG comment == $comment" }
  587. ## get iMDb rating
  588. if [regexp {<strong><span itemprop="ratingValue">(.*?)</span></strong>} $html rating] {
  589. regsub -all {<[^\>]*>} $rating {} rating
  590. #rating bar code - attempt at recreating
  591. set goldstars [expr round($rating)]
  592. set greystars [expr 10 - $goldstars]
  593.  
  594. # generating the rating bar
  595. set marker "*"
  596. set rating_bar "%color$barcol1\[%color$barcol2"
  597. for {set i2 0} {$i2 < $goldstars} {incr i2 1} {
  598. set rating_bar "$rating_bar$marker"
  599. }
  600. set marker "-"
  601. set rating_bar "$rating_bar%color$barcol2"
  602. for {set i3 0} {$i3 < $greystars} {incr i3 1} {
  603. set rating_bar "$rating_bar$marker"
  604. }
  605. set rating_bar "$rating_bar%color$barcol1\]%color"
  606. #end rating bar code
  607. }
  608.  
  609. if [regexp {<span itemprop="ratingCount">(.*?)</span>} $html votes] {
  610. regsub -all {<[^\>]*>} $votes {} votes
  611. }
  612.  
  613. #if [regexp {<b>((.*?)</b><span class="mellow">/10)</span>.*?<a .*? href="ratings".*?>(.*?) votes</a>} $html dummy rating goldstars votes] {
  614. #
  615. # regsub -all {<[^\>]*>} $rating {} rating
  616. # #rating bar code
  617. # set goldstars [expr round($goldstars)]
  618. # set greystars [expr 10 - $goldstars]
  619. # # generating the rating bar
  620. # set marker "*"
  621. # set rating_bar "$barcol1\[$barcol2"
  622. # for {set i2 0} {$i2 < $goldstars} {incr i2 1} {
  623. # set rating_bar "$rating_bar$marker"
  624. # }
  625. # set marker "-"
  626. # set rating_bar "$rating_bar14"
  627. # for {set i3 0} {$i3 < $greystars} {incr i3 1} {
  628. # set rating_bar "$rating_bar$marker"
  629. # }
  630. # set rating_bar "$rating_bar$barcol1\]"
  631. # #end rating bar code
  632. #
  633. #}
  634. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG rating == $rating | votes == $votes | rating bar == $rating_bar" }
  635. ## get TOP 250
  636. if [regexp {<strong>Top 250 #([\d]+)</strong>} $html dummy top250] {
  637. } elseif [regexp {>(Bottom 100: #[\d]+)</a>} $html dummy top250] {
  638. }
  639.  
  640. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG top250 == $top250" }
  641. ## get MPAA
  642. if [regexp {<span itemprop="contentRating">.*?</span>} $html mpaa] {
  643. regsub -all {<[^\>]*>} $mpaa {} mpaa
  644. set mpaa [string trim $mpaa]
  645. set mpaa [htmlcodes $mpaa]
  646. }
  647. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG mpaa == $mpaa" }
  648. ## get runtime
  649. if [regexp {<h4 class="inline">Runtime:</h4>.*?<time .*?>(.*?)</time>} $html dummy runtime] {
  650. regsub -all {[\n\s]+} $runtime {} runtime
  651. }
  652. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG runtime == $runtime" }
  653. ## get country
  654. if [regexp {<h4 class="inline">Country:</h4>(.*?)</div>} $html dummy country] {
  655. set country [string map {&nbsp; " "} $country]
  656. regsub -all {<[^\>]*>} $country {} country
  657. set country [string map {"|" "||" } $country]
  658. regsub -all {[\n]+} $country {} country
  659. }
  660. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG country == $country" }
  661. ## get language
  662. if [regexp {<h4 class="inline">Language:</h4>(.*?)</div>} $html dummy language] {
  663. set language [string map {"See more" "" \n "" &nbsp; " " &raquo; ""} $language]
  664. regsub -all {<[^\>]*>} $language {} language
  665. regsub -all {[\n]+} $language {} language
  666. set language [string map {"|" "||"} $language]
  667. }
  668. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG language == $language" }
  669. ## get movie color
  670. if [regexp {<h4 class="inline">Color:</h4>(.*?)</div>} $html dummy movie_color] {
  671. regsub -all {<[^\>]*>} $movie_color {} movie_color
  672. regsub -all {[\n\s]+} $movie_color {} movie_color
  673. set movie_color [string trim $movie_color]
  674. set movie_color [string map {"|" "||"} $movie_color]
  675. }
  676. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG movie_color == $movie_color" }
  677. ## get aspect ratio
  678. if [regexp {<h4 class="inline">Aspect Ratio:</h4>(.*?)</div>} $html dummy aspect_ratio] {
  679. regsub -all {<[^\>]*>} $aspect_ratio {} aspect_ratio
  680. set aspect_ratio [string map {"more" "" } $aspect_ratio]
  681. set aspect_ratio [string trim $aspect_ratio]
  682. }
  683. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG aspect_ratio == $aspect_ratio" }
  684. ## get soundmix
  685. if [regexp {<h4 class="inline">Sound Mix:</h4>(.*?)</div>} $html dummy soundmix] {
  686. set soundmix [string map {"See more" "" \n "" &nbsp; "" &raquo; ""} $soundmix]
  687. regsub -all {<[^\>]*>} $soundmix {} soundmix
  688. regsub -all {[\n]+} $soundmix {} soundmix
  689. set soundmix [string map {"|" "||"} $soundmix]
  690. }
  691. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG soundmix == $soundmix" }
  692. ## get certification
  693. if [regexp {<div class="infobar">.*?alt="(.*?)"} $html dummy cert] {
  694. regsub -all {<[^\>]*>} $cert {} cert
  695. set mpaa [string trim $cert]
  696. set mpaa [htmlcodes $cert]
  697. }
  698. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG cert == $cert" }
  699. ## get locations
  700. if { [regexp {<h4 class="inline">Filming Locations:</h4>(.*?)</div>} $html dummy film_locations] } {
  701. set film_locations [string map {"See more" "" &raquo; ""} $film_locations]
  702. regsub -all {<[^\>]*>} $film_locations {} film_locations
  703. regsub -all {[\n\s]+} $film_locations { } film_locations
  704. set film_locations [string trim $film_locations]
  705. set film_locations [htmlcodes $film_locations]
  706. }
  707. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG film_locations == $film_locations" }
  708. ## get company
  709. if [regexp {<h3>Company Credits</h3>(.*?)</div>} $html dummy company] {
  710. set company [string map {"See more" "" &nbsp; "" &raquo; ""} $company]
  711. regsub -all {<[^\>]*>} $company {} company
  712. regsub -all {[\n\s]+} $company { } company
  713.  
  714. set company [string trim $company]
  715. }
  716. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG company == $company" }
  717.  
  718. ## get cast
  719. if [regexp {<table class="cast_list">(.*?)</table>} $html dummy cast] {
  720. regsub -all {</tr>.*?<tr.*?>} $cast "\n" cast_multiline
  721. regsub -all {[\n]+} $cast_multiline {} cast_multiline
  722. regsub -all {<[^\>]*>} $cast_multiline {} cast_multiline
  723. set cast_multiline [string map {"rest of cast listed alphabetically:" \n} $cast_multiline]
  724. set cast_multiline [string trim [join [htmlcodes $cast_multiline]]]
  725. if { $cast_linelimit > 0 } {
  726. set nthoccur [expr [findnth $cast_multiline \n $cast_linelimit] - 1]
  727. if {$nthoccur > 0} {set cast_multiline [string range $cast_multiline 0 $nthoccur]}
  728. }
  729. }
  730. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG cast_multiline == $cast_multiline" }
  731. ## fill singleline
  732. regsub -all {\n} $cast_multiline " / " cast_line
  733. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG cast_line == $cast_line" }
  734.  
  735. ## get budget
  736. if [regexp {<h4 class="inline">Budget:</h4> (.*?)</div>} $html dummy budget] {
  737. regsub -all {[\n]+} $budget {} budget
  738. set budget [string map {ˆ ˆ ? ?} $budget]
  739. }
  740. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG budget == $budget" }
  741. ## get screens
  742. if [regexp {<h4 class="inline">Opening Weekend:</h4>\n(.*?Screens\))} $html dummy screens] {
  743. regsub -all {[\n]+} $screens { } screens
  744. regsub -all {<[^\>]*>} $screens {} screens
  745. set screens [htmlcodes $screens]
  746. }
  747. if {$IMDB_DEBUG == 1} { putlog "IMDB_DEBUG screens == $screens" }
  748.  
  749. ## output results
  750.  
  751. #cleaning the end url
  752. set cleanurl [string map {"akas." ""} $newurl]
  753. set output [string map [list "%title" "$title" "%aka" "$aka" "%url" "$cleanurl" "%name" "$name" "%genre" "$genre" "%tagline" "$tagline" "%plot" "$plot" "%keywords" "$keywords" "%awards" "$awards" "%comment" "$comment" "%rating" "$rating" "%rbar" "$rating_bar" "%votes" "$votes" "%top250" "$top250" "%mpaa" "$mpaa" "%time" "$runtime" "%country" "$country" "%language" "$language" "%mcolor" "$movie_color" "%aspect" "$aspect_ratio" "%soundmix" "$soundmix" "%cert" "$cert" "%locations" "$film_locations" "%company" "$company" "%budget" "$budget" "%screens" "$screens" "%reldate" "$reldate"] $output]
  754. set checkvar ""
  755. regexp {.*?%castmline} $output checkvar
  756. if { [expr [regexp -all {%uline} $checkvar] % 2] == 1 } {
  757. set cast_multiline [string map {"\n" "\n%uline"} $cast_multiline]
  758. }
  759. if { [expr [regexp -all {%bold} $checkvar] % 2] == 1 } {
  760. set cast_multiline [string map {"\n" "\n%bold"} $cast_multiline]
  761. }
  762. if { [regexp {.*%color([\d]+(?:,[\d]+)?)[^\n]*?%castmline} $checkvar dummy colormline] } {
  763. regsub -all {\n} $cast_multiline "\n%color$colormline" cast_multiline
  764. }
  765. set output [replacevar $output "%castmline" $cast_multiline]
  766. set output [replacevar $output "%castline" $cast_line]
  767. set output [replacevar $output "%wcredits" $wcredits]
  768. regsub -all {\|[^\|]*?N/A[^\|]*?\|} $output "" output
  769. set output [string map {"||" "|" "|" ""} $output]
  770. regsub -all {\n[\n\s]*\n} $output "\n" output
  771. set output [string trim $output]
  772. set output [replacevar $output "%bold" "\002"]
  773. set output [replacevar $output "%uline" "\037"]
  774. set output [replacevar $output "%bull" "\u2022"]
  775. set output [replacevar $output "%color" "\003"]
  776. set output [encoding convertto utf-8 $output]
  777. foreach line [split [imdb_decode $output] "\n"] {
  778. while {$line != ""} {
  779. puthelp "$toput :[string range $line 0 399]"
  780. set line [string range $line 400 end]
  781. }
  782. }
  783. set imdb(lasttime,$chan) [clock seconds]
  784. }
  785.  
  786. proc wmsg { } {
  787. global warn_msg
  788. set warn_msg 0
  789. }
  790.  
  791. proc imdb_decode {text {char "utf-8"} } {
  792. # code below is neccessary to prevent numerous html markups
  793. # from appearing in the output (ie, &quot;, ?, etc)
  794. # stolen (borrowed is a better term) from tcllib's htmlparse ;)
  795. # works unpatched utf-8 or not, unlike htmlparse::mapEscapes
  796. # which will only work properly patched....
  797. set escapes {
  798. &nbsp; \xa0 &iexcl; \xa1 &cent; \xa2 &pound; \xa3 &curren; \xa4
  799. &yen; \xa5 &brvbar; \xa6 &sect; \xa7 &uml; \xa8 &copy; \xa9
  800. &ordf; \xaa &laquo; \xab &not; \xac &shy; \xad &reg; \xae
  801. &macr; \xaf &deg; \xb0 &plusmn; \xb1 &sup2; \xb2 &sup3; \xb3
  802. &acute; \xb4 &micro; \xb5 &para; \xb6 &middot; \xb7 &cedil; \xb8
  803. &sup1; \xb9 &ordm; \xba &raquo; \xbb &frac14; \xbc &frac12; \xbd
  804. &frac34; \xbe &iquest; \xbf &Agrave; \xc0 &Aacute; \xc1 &Acirc; \xc2
  805. &Atilde; \xc3 &Auml; \xc4 &Aring; \xc5 &AElig; \xc6 &Ccedil; \xc7
  806. &Egrave; \xc8 &Eacute; \xc9 &Ecirc; \xca &Euml; \xcb &Igrave; \xcc
  807. &Iacute; \xcd &Icirc; \xce &Iuml; \xcf &ETH; \xd0 &Ntilde; \xd1
  808. &Ograve; \xd2 &Oacute; \xd3 &Ocirc; \xd4 &Otilde; \xd5 &Ouml; \xd6
  809. &times; \xd7 &Oslash; \xd8 &Ugrave; \xd9 &Uacute; \xda &Ucirc; \xdb
  810. &Uuml; \xdc &Yacute; \xdd &THORN; \xde &szlig; \xdf &agrave; \xe0
  811. &aacute; \xe1 &acirc; \xe2 &atilde; \xe3 &auml; \xe4 &aring; \xe5
  812. &aelig; \xe6 &ccedil; \xe7 &egrave; \xe8 &eacute; \xe9 &ecirc; \xea
  813. &euml; \xeb &igrave; \xec &iacute; \xed &icirc; \xee &iuml; \xef
  814. &eth; \xf0 &ntilde; \xf1 &ograve; \xf2 &oacute; \xf3 &ocirc; \xf4
  815. &otilde; \xf5 &ouml; \xf6 &divide; \xf7 &oslash; \xf8 &ugrave; \xf9
  816. &uacute; \xfa &ucirc; \xfb &uuml; \xfc &yacute; \xfd &thorn; \xfe
  817. &yuml; \xff &fnof; \u192 &Alpha; \u391 &Beta; \u392 &Gamma; \u393 &Delta; \u394
  818. &Epsilon; \u395 &Zeta; \u396 &Eta; \u397 &Theta; \u398 &Iota; \u399
  819. &Kappa; \u39A &Lambda; \u39B &Mu; \u39C &Nu; \u39D &Xi; \u39E
  820. &Omicron; \u39F &Pi; \u3A0 &Rho; \u3A1 &Sigma; \u3A3 &Tau; \u3A4
  821. &Upsilon; \u3A5 &Phi; \u3A6 &Chi; \u3A7 &Psi; \u3A8 &Omega; \u3A9
  822. &alpha; \u3B1 &beta; \u3B2 &gamma; \u3B3 &delta; \u3B4 &epsilon; \u3B5
  823. &zeta; \u3B6 &eta; \u3B7 &theta; \u3B8 &iota; \u3B9 &kappa; \u3BA
  824. &lambda; \u3BB &mu; \u3BC &nu; \u3BD &xi; \u3BE &omicron; \u3BF
  825. &pi; \u3C0 &rho; \u3C1 &sigmaf; \u3C2 &sigma; \u3C3 &tau; \u3C4
  826. &upsilon; \u3C5 &phi; \u3C6 &chi; \u3C7 &psi; \u3C8 &omega; \u3C9
  827. &thetasym; \u3D1 &upsih; \u3D2 &piv; \u3D6 &bull; \u2022
  828. &hellip; \u2026 &prime; \u2032 &Prime; \u2033 &oline; \u203E
  829. &frasl; \u2044 &weierp; \u2118 &image; \u2111 &real; \u211C
  830. &trade; \u2122 &alefsym; \u2135 &larr; \u2190 &uarr; \u2191
  831. &rarr; \u2192 &darr; \u2193 &harr; \u2194 &crarr; \u21B5
  832. &lArr; \u21D0 &uArr; \u21D1 &rArr; \u21D2 &dArr; \u21D3 &hArr; \u21D4
  833. &forall; \u2200 &part; \u2202 &exist; \u2203 &empty; \u2205
  834. &nabla; \u2207 &isin; \u2208 &notin; \u2209 &ni; \u220B &prod; \u220F
  835. &sum; \u2211 &minus; \u2212 &lowast; \u2217 &radic; \u221A
  836. &prop; \u221D &infin; \u221E &ang; \u2220 &and; \u2227 &or; \u2228
  837. &cap; \u2229 &cup; \u222A &int; \u222B &there4; \u2234 &sim; \u223C
  838. &cong; \u2245 &asymp; \u2248 &ne; \u2260 &equiv; \u2261 &le; \u2264
  839. &ge; \u2265 &sub; \u2282 &sup; \u2283 &nsub; \u2284 &sube; \u2286
  840. &supe; \u2287 &oplus; \u2295 &otimes; \u2297 &perp; \u22A5
  841. &sdot; \u22C5 &lceil; \u2308 &rceil; \u2309 &lfloor; \u230A
  842. &rfloor; \u230B &lang; \u2329 &rang; \u232A &loz; \u25CA
  843. &spades; \u2660 &clubs; \u2663 &hearts; \u2665 &diams; \u2666
  844. &quot; \x22 &amp; \x26 &lt; \x3C &gt; \x3E O&Elig; \u152 &oelig; \u153
  845. &Scaron; \u160 &scaron; \u161 &Yuml; \u178 &circ; \u2C6
  846. &tilde; \u2DC &ensp; \u2002 &emsp; \u2003 &thinsp; \u2009
  847. &zwnj; \u200C &zwj; \u200D &lrm; \u200E &rlm; \u200F &ndash; \u2013
  848. &mdash; \u2014 &lsquo; \u2018 &rsquo; \u2019 &sbquo; \u201A
  849. &ldquo; \u201C &rdquo; \u201D &bdquo; \u201E &dagger; \u2020
  850. &Dagger; \u2021 &permil; \u2030 &lsaquo; \u2039 &rsaquo; \u203A
  851. &euro; \u20AC &apos; \u0027 &lrm; "" &rlm; ""
  852. };
  853. if {![string equal $char [encoding system]]} { set text [encoding convertfrom $char $text] }
  854. set text [string map [list "\]" "\\\]" "\[" "\\\[" "\$" "\\\$" "\"" "\\\"" "\\" "\\\\"] [string map -nocase $escapes $text]]
  855. regsub -all -- {&#([[:digit:]]{1,5});} $text {[format %c [string trimleft "\1" "0"]]} text
  856. regsub -all -- {&#x([[:xdigit:]]{1,4});} $text {[format %c [scan "\1" %x]]} text
  857. catch { set text "[subst "$text"]" }
  858. if {![string equal $char [encoding system]]} { set text [encoding convertto $char $text] }
  859. return "$text"
  860. }
  861.  
  862. putlog "IMDB Info Version 17.01.2013: LOADED"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement