Script to download TwoKinds

For tech wizards and n00bs alike. Questions, answers, or just general hoo-haa.

Moderator: Moderators

Post Reply
Message
Author
User avatar
philip284
Apprentice
Posts: 137
Joined: Sun Jan 01, 2012 1:25 am

Script to download TwoKinds

#1 Post by philip284 »

EDIT: It is now hosted on github https://github.com/philip284/TwoKinds-Download-Script

Hey, I just finished my scripts to download TwoKinds.

Here it is. TwoKinds Download Script

For using this you would need a PHP server, so you could do this http://www.howtogeek.com/howto/14998/tu ... web-server and get one on a flash drive.

Once you have uploaded, navigate to index.php, the errors will disappear once you click update and let it run.

Note: it will not get the newest one and does not require a database
If a tree falls in the woods, but no one is around to hear it, does it still kill the squirrel it landed on?
ImageImage

User avatar
aj
Consistently Inconsistent
Posts: 1725
Joined: Wed Jul 30, 2008 10:13 am

Re: Script to download TwoKinds

#2 Post by aj »

Oh god, another scraper! The VPS can't handle- Oh, wait. I don't care about that anymore now Keenspot does the hosting.

So, Yay! Someone's doing nifty stuff with the site!
===
Now, a few questions about the script itself. Warning - I love optimization.
  • What do file.php and variables.php do? (Seemingly nothing, as far as I can tell. No references outside of those two files.)
  • savejsoncomic.php seems to be a testing file, any reason it was included?
  • The function objectToArray doesn't have to be in index.php, view.php and update.php - you're already requiring mainclass.php, you can just declare it in there.
  • Actually, as far as I can tell, the only purpose of objectToArray the JSON object to an array. json_decode can automatically do that (2nd parameter), so having the function isn't strictly necessary.
  • The date code in view.php is... overly complicated, and can be condensed.

    Code: Select all

    $day = date("l", $timestamp);
    $month = date("F", $timestamp);
    $date = $day . ", " . $month ." ". date("j", $timestamp)  . "<span style=\"font-size:xx-small; vertical-align:top;\">".date("S", $timestamp)."</span>".", ".date("Y", $timestamp);
    can be condensed into

    Code: Select all

    $date =  $timestamp->format("l, F j")."<span style='font-size:xx-small; vertical-align:top;'>".$timestamp->format("S")."</span>".$timestamp->format(", Y");
As a reference for the last point, this is the code that runs on the front page ($file is the filename):

Code: Select all

$unixtime = DateTime::createFromFormat("Ymd", substr($file,0,8));
$date =  $unixtime->format("l, F j")."<span style='font-size:xx-small; vertical-align:top;'>".$unixtime->format("S")."</span>".$unixtime->format(", Y");
On a completely different note, might I recommend using GitHub? Its integration with git is particularly useful, and the zipped download file will be automagically updated whenever you upload some changes. (That's if you are using git. If you're using an alternate CVS, no problem. But if you're not, git is a great place to start. I found it invaluable while working on the RSS and archive scripts.)

Nice work though. I didn't know there was a PHP script that would parse a HTML page. I learnt something! :)
avwolf wrote:"No dating dog-girls, young man, your father is terribly allergic!"
y̸̶o͏͏ų̕ sh̡o̸̵u̶̕l̴d̵̡n̵͠'̵́͠t͜͢ ̀͜͝h̶̡àv̸e͡ ̛d̷̨͡o͏̀ne ̶͠͡t҉́h̕a̧͞t̨҉́.̵̧͞.͠͞.͟

User avatar
philip284
Apprentice
Posts: 137
Joined: Sun Jan 01, 2012 1:25 am

Re: Script to download TwoKinds

#3 Post by philip284 »

Ok, It is at github now https://github.com/philip284/TwoKinds-Download-Script.

Going to update everything later today.

EDIT: Everything is updated
Also $timestamp is not an object
Also file.php and variables.php were their because it was part of a CMS I was making and I just used the main code when I copied and pasted, and savejsoninstall.php was a testing file, I include it for no reason.
If a tree falls in the woods, but no one is around to hear it, does it still kill the squirrel it landed on?
ImageImage

Post Reply