Top

ExPlOsM.NeT Comic Downloader/Viewer (v.4)


mIRC Code
+ 1 likes
Please Register to submit score.
Bookmark and Share
Average Score  7.4 (of 7 scores)
Date Added  Apr 10, 2009
Last Updated  Apr 12, 2009
Tags  .  and  comic  cyanide  explosm  happiness  kirby  net  picture  webcomic 

Description

Another example of the power of binaries and hashes to produce image downloading, however slightly modified.

Basically, the script gets a random webcomic from Cyanide and Happiness Comics, downloads it, and then opens it for you to view.

Syntax: /explosm

You can also download and view images via menu, including emptying/deleting directories, as shown in the picture below.

While in the window @ExPlOsM, you can press the Enter Key or the Spacebar to download and view another image from the website!

All images are downloaded to a folder called explosm.net in your mIRC Directory.

An echo regarding information on the www.explosm.net comic download is made to the Status Window.
Code:
[Cyanide and Happiness ~ X] ~ Comic: http://www.explosm.net/comics/XXXX/ ~ Submitter: Nick ~ Date: X XX XXXX ~ Direct link: http://www.explosm.net/db/files/Comics/XXXXXXXXXX.XXX

If you want for it to echo in your active channel/query, change the timer to this:
Code:
  .timerexplosm 1 2 echo -e $lactive [Cyanide and Happiness ~ $+($calc($findfile(explosm.net,*,0,0) + 1),]) ~ Comic: $+(,$+(http://,$sock(explosm2).addr,$1),) ~ Submitter: $+(,$3,) ~ Date: $+(,$gettok(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec,$gettok($4,1,46),32) $ord($abs($gettok($4,2,46))) $gettok($4,3,46),) ~ Direct link: $+(,$2,)


*** Note: mIRC Version 6.35 works most effectively. Download it here if you want to experience best possible results.


Thanks to ^Neptune for introducing me to this and TheImrac for the awesome alias.

Here's a picture:


Here's another picture:



Enjoy! :D

Grab the Code

;SOF
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;         Explosm Cyanide & Happiness WebComic         ;
;               Made by Kirby (Quakenet)               ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
 
; // ... Download + View a comic ... Syntax: /explosm ... //
alias explosm {
  if (!$sock(explosm)) && (!$sock(explosm2)) sockopen explosm www.explosm.net 80
}
 
; // Download + View a comic / Clear Directory //
menu * {
  ExPlOsM.NeT~! $+($chr(40),$findfile(explosm.net,*,0,0) $iif($findfile(explosm.net,*,0,0) == 1,comic,comics),$chr(41))
  .Download + View $iif($findfile(explosm.net,*,0,0) == 0,a,another) comic : explosm
  .$iif($abs($findfile(explosm.net\,*,0,0)) == 0,$style(6) Clear bin,$style(4) Clear bin) : noop $findfile(explosm.net\,*,0,0,.remove $qt($1-)) | noop $input(Done. Deleted all files in the directory $mircdirexplosm.net,iok2,Attention!)
  .$iif($abs($findfile(explosm.net\,*,0,0)) != 0,$iif($isdir(explosm.net),$style(4) Delete all,$style(6) Delete all),$style(6) Delete all) : noop $findfile(explosm.net\,*,0,0,.remove $qt($1-)) | rmdir explosm.net | noop $input(Done. Deleted directory $mircdirexplosm.net,iok2,Attention!)
  .-
  .$iif($isdir(explosm.net),$style(4) Open comic folder,$style(6) Open comic folder) : run $mircdirexplosm.net
}
 
; // Identifiers used in the sockets //
alias -l addmark { return $+($sock($1).mark,$chr($3),$2) }
alias -l between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
alias -l htmlfree { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) | return $remove($replace(%x,&quot;,",&lt;,<,&gt;,>,$cr,$chr(32),$lf,$chr(32),&amp;,&,&#34;,",&#226;,$chr(226),&#183;,·,&#233;,é,&#38;,$chr(38),&#x22;,",&#x27;,',&#x26;,&,&#xF4;,ô,&#xB7;,·,&#xE9;,é),$chr(9)) }
 
; // ExPlOsM.NeT WebComic Socket Step #1 (Get link) //
on *:sockopen:explosm: {
  sockwrite -n $sockname GET /comics/random/ HTTP/1.1
  sockwrite -n $sockname Host: www.explosm.net $+ $crlf $+ $crlf
}
on *:sockread:explosm: {
  sockread %explosm
  if (Location: isin %explosm) sockmark explosm $gettok($v2,2,32))
}
on *:sockclose:explosm: {
  sockopen explosm2 www.explosm.net 80
  sockmark explosm2 $sock(explosm).mark
}
 
; // ExPlOsM.NeT WebComic Socket Step #2 (Download image) //
on *:sockopen:explosm2: {
  sockwrite -n $sockname GET $sock(explosm2).mark HTTP/1.1
  sockwrite -n $sockname Host: www.explosm.net $+ $crlf $+ $crlf
}
on *:sockread:explosm2: {
  sockread %explosm2
  if (<td width=240> isin %explosm2) sockmark explosm2 $addmark(explosm2,$+($between($v2,a daily webcomic" src=","></div>,1),$chr(32),$htmlfree($between($v2,$+(<b>by,$chr(32)),</b>,1)),$chr(32),$between($v2,colspan=2>,$+($chr(32),<b>),1)),32)
}
on *:sockclose:explosm2: {
  tokenize 32 $sock(explosm2).mark
  if (!$isdir(explosm.net)) mkdir explosm.net
  img_download -oak loadimg $2 explosm.net\
  .timerexplosm 1 2 echo -se [Cyanide and Happiness ~ $+($calc($findfile(explosm.net,*,0,0) + 1),]) ~ Comic: $+(,$+(http://,$sock(explosm2).addr,$1),) ~ Submitter: $+(,$3,) ~ Date: $+(,$gettok(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec,$gettok($4,1,46),32) $ord($abs($gettok($4,2,46))) $gettok($4,3,46),) ~ Direct link: $+(,$2,)
  unset %explosm*
}
 
;// ExPlOsM.NeT WebComic Viewer (@Window) //
menu @ExPlOsM {
  Minimize comic: window -n @ExPlOsM
  Close comic : window -c @ExPlOsM
}
on *:keydown:@ExPlOsM:*: {
  if (!$keyrpt) {
    if ($keyval == 13) || ($keyval == 32) explosm
    elseif ($keyval == 27) window -c @ExPlOsM
  }
}
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;         TheImrac's "Image-Downloader"         ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
 
alias -l bet { var %reg $+(/,$2,(.+?),$3,/i) | %reg = $regex($1,%reg) | return $regml($4) }
alias img_download {
  if ($regex(par,$1,/^(-[uakmos]{1,6})/i)) {
    var %flgs = $regml(par,1)
    if (a isin %flgs) && (u isin %flgs) { var %a = $2, %u = $3, %1 = $4, %2- $5- }
    elseif (a isin %flgs) { var %a = $2, %1 = $3, %2- $4- }
    elseif (u isin %flgs) { var %a = $2, %1 = $3, %2- $4- }
    else { var %1 = $2, %2- $3- }
  }
  else { var %1 = $1, %2- = $2- }
  if ($regex(img,%1,/^((?:https?://)((?:www.)?[^/]*)(.*/([^/]*\.(jpg|gif|bmp|png))))$/i)) && (%2-) {
    var %f = $qt(%2-)    
    if (k isin %flgs)  {
      if ($nofile(%f) == $noqt(%f)) { var %f = $qt($noqt(%f) $+ $regml(img,4)) }
      else { echo -qeag * /img_download: Invalid Directory Name. | halt }
    }
    if ($exists(%f)) && (o !isin %flgs) { echo -eqag * /imgfile: %f Already Exists. | halt }
    if (!$exists($nofile(%f))) && (m !isin %flgs) { echo -eqag * /img_download: $qt($nofile(%f)) Directory Does Not Exist. | halt }
    if ($right($noqt(%f),3) != $regml(img,5)) { echo -qeag * /img_download: Invalid File Name. | halt }
    else {
      var %x = imgdl_ $+ $regml(img,1)
      hadd -m %x full $regml(img,1)
      hadd %x host $regml(img,2)
      hadd %x get $regml(img,3)
      hadd %x dlfile $regml(img,4)
      hadd %x file %f
      hadd %x time $ticks
      if (%flgs) { hadd %x flgs %flgs }
      if (%a) hadd %x alias %a
      if (%u) hadd %x update %u
      .sockclose %x
      .sockopen %x $hget(%x,host) 80
    }
  }
  else echo -qeag * /img_download: Invalid Parameters.
}
on *:sockopen:imgdl_*:{
  if ($sockerr) { img_fail $sockname }
  else {
    sockwrite -n $sockname GET $hget($sockname,get) HTTP/1.1 
    sockwrite -n $sockname Host: $hget($sockname,host)
    sockwrite -n $sockname
  } 
}
on *:sockread:imgdl_*:{ 
  if ($sockerr) { img_fail $sockname }
  if (!$sock($sockname).mark) { 
    var %x = $true  
    while (%x) { 
      sockread %x
      if ($regex(%x,/^Content-Length: (\d+)$/i)) { hadd $sockname size $regml(1) }
      if ($regex(%x,/^Content-Type: (.*)$/i)) { if (!$regex($regml(1),/^image/.*$/)) { img_fail $sockname | halt } } 
      sockmark $sockname $true 
    }
  }
  else {
    while ($sock($sockname).rq) {
      sockread &img
      noop $hget($sockname,bvar,&temp) 
      bcopy &temp $calc($bvar(&temp,0) + 1) &img 1 -1
      var %size = $bvar(&temp,0)    
      hadd -b $sockname bvar &temp
      if (%size == $hget($sockname,size)) img_close
      else { if ($hget($sockname,update)) { $v1 %size $hget($sockname,size) $calc($ticks - $hget($sockname,time)) $hget($sockname,full) $hget($sockname,file) } }
    }  
  }
}
alias -l img_close {
  var %mz = $calc($ticks - $hget($sockname,time)), %size = $bvar(&temp,0) 
  if (o isin $hget($sockname,flgs)) .remove $hget($sockname,file)
  if (m isin $hget($sockname,flgs)) .mkdir $nofile($hget($sockname,file)) 
  bwrite $hget($sockname,file) -1 -1 &temp    
  if (s isin $hget($sockname,flgs)) {
    var %s = $calc(($ticks - $hget($sockname,time)) / 1000), %sz = $calc($bvar(&temp,0) / 1024) 
    echo -eag Downloaded $hget($sockname,file) ( $+ $round(%sz,2) kb $+ ) Took %s Seconds at $round($calc(%sz / %s ),2) kbps 
  }
  if (r isin $hget($sockname,flgs)) { run $hget($sockname,file) }
  if ($hget($sockname,alias)) { $v1 $hget($sockname,full) %mz %size $pic($hget($sockname,file)).width $pic($hget($sockname,file)).height $hget($sockname,file) }
  hfree $sockname
  sockclose $sockname
}
alias -l img_fail {
  if ($sock($1)) sockclose $1
  if ($hget($1,alias)) { $v1 $hget($sockname,full) }
  hfree $1
}
alias loadimg {
  if (!$2) echo -e Error Downloading File $1
  else {
    if ($window(@ExPlOsM)) window -c @ExPlOsM
    if ($4 > $calc($window(-3).w * .75)) || ($5 > $calc($window(-3).h * .75)) { 
      if ($4 >= $5) { var %w = $round($calc(.75 * $window(-3).w),0), %h = $round($calc(%w * $5 / $4),0) }
      else { var %h = $round($calc(.75 * $window(-3).h),0), %w = $round($calc(%h * $4 / $5),0) }
    }
    else var %w = $4, %h = $5
    window -dapBCw3 +d @ExPlOsM 50 50 %w %h
    drawpic -s @ExPlOsM 0 0 %w %h $6-
  }
}
 
 
;EOF

Comments

  (17)  RSS
Aucun50
Comments: 568
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 11, 2009 1:53 am
Interesting, I'll have to try that one out love the idea and what you did with it.
Aucun50
Comments: 568
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 11, 2009 9:47 pm
I gave it a try and it didn't get an error runs smoothly to good job. I think for the attention thing it need more of a timer like 5-7 seconds i didn't even get to read it or maybe it lagged for me not sure.
Kirby
Comments: 480
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 11, 2009 9:53 pm
Made more updates.

Please read the description carefully before you use this.
Kirby
Comments: 480
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 11, 2009 10:03 pm
Quote:
I gave it a try and it didn't get an error runs smoothly to good job. I think for the attention thing it need more of a timer like 5-7 seconds i didn't even get to read it or maybe it lagged for me not sure.

I think I'll add a timer...perhaps 5 seconds? I've made some updates to the introduction and the code a bit (not sure if you checked it out when you posted).
Echo is now made to the status window too.
Aucun50
Comments: 568
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 12:28 am
Nice, thanks for adding the timer helps a lot
94killerz
Comments: 20
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 9:59 am
Haha, Kris Wilson = Awesomeness.
Aucun50
Comments: 568
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 6:24 pm
I love how they don't post why, would be nice to know what to improve on not just say it's crap.
Firstmate
Comments: 125
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 6:27 pm
What did Neptune and Imrac give you?
^Neptune
Comments: 629
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 7:02 pm
Still not sure why I'm in the credits - it's not my image downloading alias at all.
Kirby
Comments: 480
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 12, 2009 7:20 pm
Firstmate said:
Quote:
What did Neptune and Imrac give you?

^Neptune said:
Quote:
Still not sure why I'm in the credits - it's not my image downloading alias at all.

Well, ^Neptune introduced me to this and showed me basics of how to use it. TheImrac was the original maker, though he didn't post the exact version that I have here.
Prelude
Comments: 98
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 14, 2009 2:11 pm
7/10 kirbz.
Kirby
Comments: 480
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Apr 14, 2009 2:46 pm
Thanks Nem.
gooshie
Comments: 181
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Oct 13, 2009 10:12 pm
This is a well thought out fun addon.
I tried it. It worked. I didn't even
want to look through all that code and
try to find any ways to improve it.
The only thing I did was make it so it
only appears in my top menubar menu.
I may color the link to the webpage
where it echos to status so I can spot
it for copy pasting when I see one I
wish to share. I gave it a like.
sunslayer
Comments: 420
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Oct 13, 2009 10:44 pm
should prolly think about adding a confirmation thing before it deletes the pics
Ghost-writer
Comments: 353
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Oct 14, 2009 5:05 am
I like it :). Very good use of msl scripting. - The coding is also great :P.

But alask, nothing is perfect.

Quote:

[Cyanide and Happiness ~ 8] ~ Comic: http://www.explosm.net/comics/1706/ ~ Submitter: 01.13.2007 ~ Date:  ~ Direct link: Rob


Quote:

* /img_download: Invalid Parameters.

Quote:

* drawpic: error loading 'C:\WINDOWS\DESKTOP\SCHOOL HRP\MARYS MIRC\explosm.net\zchriz.gif' (line 172, script2.ini)
gooshie
Comments: 181
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Oct 14, 2009 8:20 am
Ghost-writer
That page contains a flash comic and does not
match up for sending to picture window and even
if it did would not be able to render so echos
the invaled parameter line.
http://www.explosm.net/comics/1706/
http://www.explosm.net/db/files/Movies/signpart2.swf

Perhaps Kirby could do something like:
Code:
on *:sockclose:explosm2: {
  tokenize 32 $sock(explosm2).mark
  if (!$isdir(explosm.net)) mkdir explosm.net
  if $4 {
    img_download -oak loadimg $2 explosm.net\
    .timerexplosm 1 2 echo -se [Cyanide and Happiness ~ TRUNCATED CODE
  }
  else { echo -s add code to try again 2-5 times before abort/error }
  unset %explosm*
}


I did just notice that some large comics are shrunk as to make
them unreadable ==> http://www.explosm.net/comics/1403/
Can't figure a good work arround right now.

I still like it tho
^Neptune
Comments: 629
 
mIRC Snippet:  ExPlOsM.NeT Comic Downloader/Viewer (v.4)
Posted on Oct 25, 2009 9:25 am
Quote:
I like it :). Very good use of msl scripting. - The coding is also great :P.


Code:
alias explosm { run www.explosm.net }

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom