Marc 48 Posted April 8, 2004 Share Posted April 8, 2004 Hi, I suppose you'll consider me nuts, but I really did it: wrote a script which downloads the current strips from Garfield, Calvin & Hobbes and Dilbert. Garfield and Calvin are easy, just have to calculate the filename from the current date and download it. Dilbert is a real bitch, the filename is filled with other numbers by random, even the length can vary... so I just download the comic and give it a new name based on the current date without analysing the original name. After downloading, the script moves the strips into the according directories and checks for missing strips in these directories. Note: there may not be any other files into these directories, otherwise the check routine will fail. After moving, irfanview is called to show the new strips. expandcollapse popupGlobal $dilbert ; some path settings $irfanview = "c:\programme\irfanview\i_view32.exe " $pfad_calvin = "d:\bilder\comics\calvin\1993\" $pfad_garfield = "d:\bilder\comics\garfield\2004\" $pfad_dilbert = "d:\bilder\comics\dilbert\2004\" $garfield = "ga" & StringRight(@year,2) & @mon & @mday & ".gif" urldownloadtofile("http://images.ucomics.com/comics/ga/" & @year & "/" & $garfield,$garfield) $calvin = "ch" & StringRight(@year - 11,2) & @mon & @mday & ".gif" urldownloadtofile("http://images.ucomics.com/comics/ch/" & @year - 11 & "/" & $calvin,$calvin) Dilbert() FileMove ($calvin, $pfad_calvin) FileMove ($garfield, $pfad_garfield) FileMove ($dilbert, $pfad_dilbert) run ($irfanview & $pfad_calvin & $calvin) run ($irfanview & $pfad_garfield & $garfield) run ($irfanview & $pfad_dilbert & $dilbert) pruefen($pfad_garfield) pruefen($pfad_calvin) pruefen($pfad_dilbert) Func pruefen($pfad) local $fehlende local $schaltjahr local $monate[13] $monate[1] = 31 $monate[2] = 29 $monate[3] = 31 $monate[4] = 30 $monate[5] = 31 $monate[6] = 30 $monate[7] = 31 $monate[8] = 31 $monate[9] = 30 $monate[10]= 31 $monate[11]= 30 $monate[12]= 31 $fehlende="" $schaltjahr = StringMid($pfad,StringLen($pfad)-4,4) $schaltjahr = mod($schaltjahr,4) if $schaltjahr = 0 then $schaltjahr = 1 else $schaltjahr = 0 Endif $search = FileFindFirstFile($pfad & "*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $file = FileFindNextFile($search); "." $file = FileFindNextFile($search); ".." $file = FileFindNextFile($search) $tag = 1 $mon = 1 While 1 If @error Then ExitLoop $datei_mon = Int(StringMid($file,5,2)) $datei_tag = Int(StringMid($file,7,2)) if ($datei_tag<>$tag) or ($datei_mon<>$mon) then if ($schaltjahr = 0) and ($mon=2) and ($tag=29) then else $fehlende=$fehlende & $mon & "-" & $tag & @CRLF endif else $file = FileFindNextFile($search) endif $tag = $tag + 1 if $tag > $monate[$mon] then $tag=1 $mon = $mon+1 if $mon>12 then ExitLoop EndIf WEnd ; Close the search handle FileClose($search) if $fehlende <>"" then Msgbox(0,$pfad, $fehlende) EndFunc Func Dilbert() urldownloadtofile("http://www.dilbert.com/comics/dilbert/archive/index.html","temp.dat") $file = FileOpen("temp.dat", 0) While 1 $line = FileReadLine($file) $position = StringInStr($line,"Today's Dilbert Comic") If $position <>0 then ExitLoop Wend FileClose($file) FileRecycle ("temp.dat") $position2 = StringInStr($line,'<IMG SRC="/comics/dilbert/archive/images/') $position2 = $position2 + 41 $datei = StringMid ($line, $position2, ($position-$position2)-16) $dilbert = "di" & StringRight(@year,2) & @mon & @mday & StringMid($datei,StringLen($datei)-3,4) urldownloadtofile("http://www.dilbert.com/comics/dilbert/archive/images/" & $datei,$dilbert) EndFunc Have fun with it Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
ezzetabi 4 Posted April 9, 2004 Share Posted April 9, 2004 Advice, change: FileMove ($calvin, $pfad_calvin) FileMove ($garfield, $pfad_garfield) FileMove ($dilbert, $pfad_dilbert) with FileMove ($calvin, $pfad_calvin,1) FileMove ($garfield, $pfad_garfield,1) FileMove ($dilbert, $pfad_dilbert,1) So if you start the script twice it will work all the same Link to post Share on other sites
Marc 48 Posted April 9, 2004 Author Share Posted April 9, 2004 Indeed. Should have thought of that Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Helge 3 Posted April 14, 2004 Share Posted April 14, 2004 I've tried to do the exact same thing, though not with the same comics..Couldn't figure it out...Link : Pondus Link to post Share on other sites
ezzetabi 4 Posted April 14, 2004 Share Posted April 14, 2004 checks for missing strips in these directories.How this part should work?I do not use the script everyday and it never downloaded comix I did not download... Link to post Share on other sites
Marc 48 Posted April 15, 2004 Author Share Posted April 15, 2004 I do not use the script everyday and it never downloaded comix I did not download...Retrieving the missing file is a different thing... currently it only checks for missing files and pops up a messagebox if there are any missing to the current date.But its a good idea to add automatical downloads of missing parts, I'll give it a shot. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
ezzetabi 4 Posted April 15, 2004 Share Posted April 15, 2004 ... and it never said that I were missing some comic... Really it seems that this pard of the script do not work. Link to post Share on other sites
Guest rathore Posted April 15, 2004 Share Posted April 15, 2004 i tried it but it only gets me dilbert's comic... other files r created but corrupted. Link to post Share on other sites
Guest rathore Posted April 15, 2004 Share Posted April 15, 2004 i've kind of figured the problem: the other two 'cartoons' actually contained this: <HTML> <HEAD><TITLE>404 Not Found</TITLE></HEAD> <BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc"> <H2>404 Not Found</H2> The requested URL '/comics/ch/1993/ch930416.gif' was not found on this server. <HR> <ADDRESS><A HREF="http://www.acme.com/software/thttpd/">thttpd/2.25b 29dec2003</A></ADDRESS> </BODY> </HTML> and <HTML> <HEAD><TITLE>404 Not Found</TITLE></HEAD> <BODY BGCOLOR="#cc9999" TEXT="#000000" LINK="#2020ff" VLINK="#4040cc"> <H2>404 Not Found</H2> The requested URL '/comics/ga/2004/ga040416.gif' was not found on this server. <HR> <ADDRESS><A HREF="http://www.acme.com/software/thttpd/">thttpd/2.25b 29dec2003</A></ADDRESS> </BODY> </HTML> Link to post Share on other sites
Marc 48 Posted April 15, 2004 Author Share Posted April 15, 2004 Hi Rathore, since the script did/does work on my system, I' ve been amazed at your problem. However, the quoted html file is really interesting, because the script tried to get ch930416.gif which is really not on the server, because we have April, 15th not 16th. So, does your pc have the correct time/date? Or perhaps you're living in a different time zone than the US Comics server? Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Marc 48 Posted April 15, 2004 Author Share Posted April 15, 2004 @ezzetabi Funny, you should get a messagebox. Just removed one of my comics and got this message as it should be However, I have to admit that the logic how the missing files are checked is quite... stupid. Could you tell me the directory names you're using and which comics are missing? Hope this information will get me the neccessary enlightment, since I have not the slightest idea why the script stays silent. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Guest rathore Posted April 15, 2004 Share Posted April 15, 2004 Or perhaps you're living in a different time zone than the US Comics server?this was my guess too but i was reluctant to post it... can u make a change to the script where one can add (or less) hrs / mins to get it equal to gmt... then the script can autoconvert gmt to comic server's time. (the difference here will be stationary)this will make ur script more 'global'. Link to post Share on other sites
ezzetabi 4 Posted April 16, 2004 Share Posted April 16, 2004 This is the script part where it sets folders... $pfad_calvin = "C:\Download\Comix\Calvin" $pfad_garfield = "C:\Download\Comix\Garfield" $pfad_dilbert = "C:\Download\Comix\Dilbert" Link to post Share on other sites
Marc 48 Posted April 16, 2004 Author Share Posted April 16, 2004 Couldn't check it yet (because I'm at work currently), but I suppose this is caused due to the missing Backslashes at the end. Would you please try $pfad_calvin = "C:\Download\Comix\Calvin\" $pfad_garfield = "C:\Download\Comix\Garfield\" $pfad_dilbert = "C:\Download\Comix\Dilbert\" I'm excited to see what happens Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Guest rathore Posted April 16, 2004 Share Posted April 16, 2004 if u don't plan to do the change i suggested, then plz just tell me what time zone applies at ur place...i'll make the necessary changes to script. just dbl click the time in system tray -> time zone tell me ur entry. Link to post Share on other sites
Marc 48 Posted April 16, 2004 Author Share Posted April 16, 2004 Hi rathore, I've been thinking about implementing this feature - not as easy as I'd like it to be. My timezone is GMT +1 - good luck. I fiddle arround with this, gonna see how far I get. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
ezzetabi 4 Posted April 16, 2004 Share Posted April 16, 2004 It works, you were right! But I think you should adds a starting date and from that checking... I have a so long message that I cant see it all... ! Link to post Share on other sites
Marc 48 Posted April 16, 2004 Author Share Posted April 16, 2004 Ah, thats some relief About the starting date... hm, would be an option. Currently I am thinking about putting all data in an array, so it could be evalued before creating a messagebox. Gonna see.. Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Marc 48 Posted April 16, 2004 Author Share Posted April 16, 2004 Hiho,here's another version which should download the missing files - if they are available. Dilbert can be retrieved back for one month, Calvin and Garfield only 15 days.Have fun...Zip FileMade a short check, seems to work as it should Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to post Share on other sites
Gene 0 Posted April 17, 2004 Share Posted April 17, 2004 Hiho,here's another version which should download the missing files - if they are available. Dilbert can be retrieved back for one month, Calvin and Garfield only 15 days.Have fun...Zip FileMade a short check, seems to work as it should Hi Marc,Check line 141, you can't have a comment character ";" on a line with the continuation character "_". It gives a missing "then" error.Gene [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now