Advertisement
Ford

IMDB / Edit for /msg no notice

Jul 16th, 2011
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.04 KB | None | 0 0
  1. ;!IMDB Movie Search Script by Ford_Lawnmower irc.GeekShed.net #Script-Help
  2. alias -l IMDB {
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Start Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;;;; Change %tagcolor to the color you want for tags:
  5. var %tagcolor $+($chr(15),$chr(2))
  6. ;;;; Change %textcolor to the color you want for normal text
  7. var %textcolor $+($chr(15),$chr(3),04)
  8. ;;;; Change %linkcolor to the color/format you want for links
  9. var %linkcolor $+($chr(15),$chr(31))
  10. ;;;; You can change the way this script prints out by editing
  11. ;;;; %lineone, %linetwo and %linethree below.
  12. ;;;; tags must be valid and separated by a space.
  13. ;;;; valid tags are as follows: title rating votes genres
  14. ;;;; runtime director writer language country date plot
  15. ;;;; shortplot cast link trailer reviews critics
  16. ;;;; If you want to omit a line, just change it to 0
  17. var %lineone title rating votes reviews critics genres runtime director writer language country date
  18. var %linetwo plot
  19. var %linethree cast link trailer
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;End Setup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. var %sockname $+(IMDB,$network,$2,$ticks)
  22. hadd -m %sockname lineone %lineone
  23. hadd %sockname linetwo %linetwo
  24. hadd %sockname linethree %linethree
  25. sockopen %sockname www.imdb.com 80
  26. sockmark %sockname $1-2 $+(/title/,$3,/) 0 %tagcolor %textcolor %linkcolor 0 0
  27. }
  28. menu Channel,Status {
  29. .$iif($group(#IMDB) == On,$style(1)) IMDB IMDB Trigger
  30. ..$iif($group(#IMDB) == On,$style(2)) On: .enable #IMDB
  31. ..$iif($group(#IMDB) == Off,$style(2)) Off: .disable #IMDB
  32. }
  33. #IMDB on
  34. On $*:Text:/^(\+|-|!|@)IMDB.*/Si:#: {
  35. var %action $regml(1)
  36. if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
  37. if (%action == +) {
  38. if ($istok(%IMDBChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the IMDB script }
  39. else {
  40. .enable #IMDB
  41. Set %IMDBChanList $addtok(%IMDBChanList,$+($network,$chan),32)
  42. .msg $chan $nick has activated the IMDB script for $chan .
  43. }
  44. }
  45. else {
  46. if (!$istok(%IMDBChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the IMDB script }
  47. else {
  48. Set %IMDBChanList $remtok(%IMDBChanList,$+($network,$chan),1,32)
  49. .msg $chan $nick has deactivated the IMDB script for $chan .
  50. }
  51. }
  52. }
  53. elseif (!$timer($+(IMDB,$network,$nick))) && ($istok(%IMDBChanList,$+($network,$chan),32)) {
  54. .timer $+ $+(IMDB,$network,$nick) 1 6 noop
  55. var %method msg $chan
  56. GIMDB %method $2-
  57. }
  58. }
  59. alias EIMDB { GIMDB echo -a $1- }
  60. alias -l GIMDB {
  61. $1-2 Searching For: $3- .............
  62. var %sockname $+(GIMDB,$network,$2,$ticks)
  63. sockopen %sockname www.google.com 80
  64. sockmark %sockname $1-2 $+(/search?q=,$replace($3-,$chr(32),+),+site:imdb.com&rls=en&hl=en) $3-
  65. ;echo -ga $+(www.google.com/search?q=,$replace($3-,$chr(32),+),+site:imdb.com&rls=en&hl=en)
  66. }
  67. On *:sockopen:GIMDB*: {
  68. if (!$sockerr) {
  69. sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  70. sockwrite -n $sockname Host: www.google.com
  71. sockwrite -n $sockname User-Agent: Opera 9.6
  72. sockwrite -n $sockname $crlf
  73. }
  74. else { echo -st Socket Error $nopath($script) | hfree $sockname | sockclose $sockname }
  75. }
  76. On *:sockread:GIMDB*: {
  77. if ($sockerr) { echo -st Socket Error $nopath($script) | hfree $sockname | sockclose $sockname }
  78. else {
  79. sockread &GIMDB
  80. if ($bintween(&GIMDB,<h3 class="r"><a href="http://www.imdb.com/title/,/" class=l,1)) {
  81. IMDB $gettok($sock($sockname).mark,1-2,32) $v1
  82. sockclose $sockname
  83. return
  84. }
  85. elseif ($bintween(&GIMDB,Your search,</b> - did not match any documents.,1)) {
  86. $gettok($sock($sockname).mark,1-2,32) Sorry - No cannot find $gettok($sock($sockname).mark,4-,32)
  87. sockclose $sockname
  88. return
  89. }
  90. }
  91. }
  92. On *:sockclose:GIMDB*: { $gettok($sock($sockname).mark,1-2,32) Sorry - No cannot find $gettok($sock($sockname).mark,4-,32) }
  93. On *:sockopen:IMDB*: {
  94. if (!$sockerr) {
  95. sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  96. sockwrite -n $sockname Host: www.imdb.com
  97. sockwrite -n $sockname $crlf
  98. }
  99. else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  100. }
  101. On *:sockclose:IMDB*: hfree $sockname
  102. On *:sockread:IMDB*: {
  103. if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  104. else {
  105. var %IMDb | sockread %IMDb
  106. if ($regex(%imdb,/<title>([^<]*)\s-\sIMDb<\/title>/i)) { hadd -m $sockname title $+($gettok($sock($sockname).mark,5,32),Title:,$chr(32),$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1)) }
  107. elseif (<span class="title-extra"> isin %imdb) hadd -m $sockname Otitle 1
  108. elseif ($hget($sockname,Otitle)) {
  109. hadd -m $sockname title $Xchr(%imdb)
  110. hadd -m $sockname Otitle 0
  111. }
  112. elseif ($regex(%imdb,/([a-z]{6,8}:)/i)) sockmark $sockname $puttok($sock($sockname).mark,$regml(1),4,32)
  113. elseif (%imdb == <p>) sockmark $sockname $puttok($sock($sockname).mark,shortplot:,4,32)
  114. elseif (<h2>Storyline</h2> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,plot:,4,32)
  115. elseif (<table class="cast_list"> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,cast:,4,32)
  116. elseif (Release Date: isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,date:,4,32)
  117. elseif ($regex(%imdb,/>([\d\x2C]{1,})\svotes/i)) hadd -m $sockname votes $+($gettok($sock($sockname).mark,5,32),Votes:,$gettok($sock($sockname).mark,6,32)) $regml(1)
  118. elseif ($gettok($sock($sockname).mark,4,32) == shortplot:) {
  119. if ($regex(%imdb,/<p>(.*)/i)) hadd -m $sockname shortplot $+($gettok($sock($sockname).mark,5,32),Plot:,$chr(32),$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  120. sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  121. }
  122. elseif ($gettok($sock($sockname).mark,4,32) == display:) {
  123. if ($regex(%imdb,/>([\d\x2C]+)\sreviews<\/a>/i)) hadd -m $sockname reviews $+($gettok($sock($sockname).mark,5,32),Reviews:,$gettok($sock($sockname).mark,6,32)) $regml(1)
  124. }
  125. elseif ($gettok($sock($sockname).mark,4,32) == Critics:) {
  126. if ($regex(%imdb,/>([\d\x2C]+)\sreviews<\/a>/i)) hadd -m $sockname critics $+($gettok($sock($sockname).mark,5,32),Critics:,$gettok($sock($sockname).mark,6,32)) $regml(1)
  127. }
  128. elseif ($gettok($sock($sockname).mark,4,32) == runtime:) {
  129. if (min isin %imdb) {
  130. hadd -m $sockname runtime $+($gettok($sock($sockname).mark,5,32),Runtime:,$gettok($sock($sockname).mark,6,32)) %imdb
  131. sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  132. tokenize 32 $sock($sockname).mark
  133. hadd -m $sockname link $+($6,$5,Link:,$chr(32),$7,http://www.imdb.com,$3)
  134. if ($hget($sockname,lineone)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  135. if ($hget($sockname,linetwo)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  136. if ($hget($sockname,linethree)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  137. hfree $sockname
  138. sockclose $sockname
  139. return
  140. }
  141. }
  142. elseif ($gettok($sock($sockname).mark,4,32) == genres:) {
  143. if ($regex(%imdb,/">([^<]*)<\/a>/g)) hadd -m $sockname genres $+($gettok($sock($sockname).mark,5,32),Genres:,$gettok($sock($sockname).mark,6,32)) $regml(1) $regml(2) $regml(3) $regml(4) $regml(5)
  144. elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  145. }
  146. elseif ($gettok($sock($sockname).mark,4,32) == director:) {
  147. if ($regex(%imdb,/\/">([^<]*)<\/a>/)) hadd -m $sockname director $+($gettok($sock($sockname).mark,5,32),Director:,$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  148. elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  149. }
  150. elseif ($gettok($sock($sockname).mark,4,32) == writer:) {
  151. if ($regex(%imdb,/\/">([^<]*)<\/a>/)) hadd -m $sockname writer $+($gettok($sock($sockname).mark,5,32),Writer:,$gettok($sock($sockname).mark,6,32)) $Xchr($regml(1))
  152. elseif (</div> isin %imdb) sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  153. }
  154. elseif ($gettok($sock($sockname).mark,4,32) == country:) {
  155. if ($regex(%imdb,/">([^<]*)<\/a>/)) set %IMDb.Country $+($iif(%IMDb.Country,$+($v1,$chr(44))),$Xchr($regml(1)))
  156. elseif (</div> isin %imdb) {
  157. sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  158. hadd -m $sockname country $+($gettok($sock($sockname).mark,5,32),Country:,$gettok($sock($sockname).mark,6,32)) %IMDb.Country
  159. unset %IMDb.Country
  160. }
  161. }
  162. elseif ($gettok($sock($sockname).mark,4,32) == language:) {
  163. if ($regex(%imdb,/">([^<]*)<\/a>/)) set %IMDb.Language $+($iif(%IMDb.Language,$+($v1,$chr(44))),$Xchr($regml(1)))
  164. elseif (</div> isin %imdb) {
  165. sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  166. hadd -m $sockname language $+($gettok($sock($sockname).mark,5,32),Language:,$gettok($sock($sockname).mark,6,32)) %IMDb.Language
  167. unset %IMDb.Language
  168. }
  169. }
  170. elseif ($gettok($sock($sockname).mark,4,32) == plot:) {
  171. if ($regex(%imdb,/<p>(.*)/)) {
  172. tokenize 32 $sock($sockname).mark
  173. hadd -m $sockname plot $6 $+($5,Plot:,$6) $Xchr($regml(1))
  174. sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  175. }
  176. }
  177. elseif ($gettok($sock($sockname).mark,4,32) == cast: || $gettok($sock($sockname).mark,4,32) == overview:) {
  178. if ($regex(%imdb,/href="\/name\/.*\/">([^<]*)<\/a>/)) set %IMDb.Cast $+($iif(%IMDb.Cast,$+($v1,$chr(44))),$Xchr($regml(1)))
  179. elseif (</table> isin %imdb) {
  180. sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  181. hadd -m $sockname cast $+($gettok($sock($sockname).mark,5,32),Cast:,$gettok($sock($sockname).mark,6,32)) %IMDb.Cast
  182. unset %IMDb.Cast
  183. tokenize 32 $sock($sockname).mark
  184. sockmark $sockname $deltok($sock($sockname).mark,10-,32)
  185. }
  186. }
  187. elseif ($gettok($sock($sockname).mark,4,32) == date:) {
  188. if (</div> isin %imdb) {
  189. sockmark $sockname $puttok($sock($sockname).mark,$v1,4,32)
  190. tokenize 32 $sock($sockname).mark
  191. hadd -m $sockname date $+($5,Release Date:,$chr(32),$6,%IMDb.Date)
  192. unset %IMDb.Date
  193. }
  194. elseif (<span class="see-more inline"> isin %imdb) {
  195. sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
  196. unset %IMDb.Date
  197. }
  198. else set %IMDb.Date %IMDb.Date %imdb
  199. }
  200. elseif (watch trailer isin %imdb && $regex(%imdb,/<a\shref="([^<]*)"\sonclick="/)) {
  201. tokenize 32 $sock($sockname).mark
  202. hadd -m $sockname trailer $+($5,Trailer:,$chr(32),$7,http://www.imdb.com,$regml(1))
  203. }
  204. elseif (<h2>Coming soon</h2> isin %imdb || </html> isin %imdb) {
  205. tokenize 32 $sock($sockname).mark
  206. hadd -m $sockname link $+($6,$5,Link:,$chr(32),$7,http://www.imdb.com,$3)
  207. if ($hget($sockname,lineone)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  208. if ($hget($sockname,linetwo)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  209. if ($hget($sockname,linethree)) put $1-2 $regsubex($v1,/([\S]+)/g,$hget($sockname,\t))
  210. hfree $sockname
  211. sockclose $sockname
  212. return
  213. }
  214. elseif ($regex(%imdb,/\|imdb\|([^|]*)\|/)) {
  215. var %L $round($gettok($regml(1),1,47),0), %R $calc(10 - $round($gettok($regml(1),1,47),0))
  216. tokenize 32 $sock($sockname).mark
  217. hadd -m $sockname rating $+($5,Rating:,$chr(32),$5,$chr(91),$6,$str(*,%L),14,$str(*,%R),$5,$chr(93),$6) $regml(1)
  218. }
  219. }
  220. }
  221. alias -l AddMark { sockmark $sockname $addtok($sock($sockname).mark,$1-,32) }
  222. alias -l Xchr {
  223. var %return $regsubex($regsubex($1-,/&#x([A-F0-9]{1,2});/g,$chr($base($regml(\n),16,10))),/&#([0-9]{2});/g,$chr(\1))
  224. return $replacecs(%return,&ndash;,–,&middot;,·,&raquo;,»,&laquo;,«,&Uuml;,Ü,&uuml;,ü,&Aacute;,Á,&aacute;,á,&Eacute;,$&
  225. É,&eacute;,é,&Iacute;,Í,&iacute;,í,&Oacute;,Ó,&oacute;,ó,&Ntilde;,Ñ,&ntilde;,ñ,&Uacute;,Ú,&uacute;,ú,&nbsp;,$chr(32),$&
  226. &aelig;,æ,&quot;,")
  227. }
  228. alias -l Put {
  229. if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { return }
  230. var %tokens $0, %Tstart 4, %Dtimer 1500
  231. if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }
  232. while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
  233. dec %tokens
  234. if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
  235. .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  236. inc %Dtimer 1500
  237. %Tstart = $calc(%tokens + 1)
  238. %tokens = $0
  239. }
  240. }
  241. .timer -m 1 %Dtimer $1-3 $($+($,%Tstart,-,%tokens),2))
  242. .timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
  243. }
  244. alias -l bintween {
  245. var %count = 1, %mark = 0, %mark2 = 0
  246. while (%count <= $4) {
  247. if ($bfind($1, %mark2, $2).text) {
  248. %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
  249. if ($bfind($1, %mark, $3).text) {
  250. %mark2 = $bfind($1, %mark, $3).text
  251. }
  252. else { return 0 }
  253. }
  254. else { return 0 }
  255. inc %count
  256. }
  257. return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement