logo sykohpath.com

				where code goes to die
			
	
tagstagstagstags
1332523761

MyAnimeList Signature Generator

ok, time for a long script!

This generates an image that shows your recent viewing history on My Anime List.  Of course, it's all tuned for me, but it's all easily changeable.  I've seen a few signatures for MAL already, but I didn't like how they worked, exactly.  Some were just plain badly coded (not that mine is 100% perfect), so I decided to write my own (viewable here):

Code Sample:
  1. <?php
  2. /* -----------------------
  3. MyAnimeList.net User History Signature Generator ()
  4. ----------------------- */
  5. $url = "http://myanimelist.net/rss.php?type=rw&u=" . $_GET['u'];
  6. $file = fopen&#40;"$url", "r"&#41;;
  7. //store page contents into buffer
  8. if (!$file) {
  9.   //if we can't create a file MAL is down, so create appropriate message as image instead!
  10.   $image = imagecreate(600,110);
  11.   $textcolor = imagecolorallocate($image, 255,255,255);
  12.   imagestring($image, 5, 85,26, "Unable to connect to MyAnimeList.net", $textcolor);
  13.   exit; //should make this end prettier
  14. } else {
  15.   $buffer = "";
  16.   while (!feof($file)) {
  17.    $buffer .= fgets($file,1024);
  18.   }
  19.   fclose($file);
  20. }
  21. //strip special chars
  22. $buffer = str_replace("n", "", $buffer);
  23. $buffer = str_replace("r", "", $buffer);
  24. $buffer = str_replace("t", "", $buffer);
  25. //parse RSS tags
  26.   //grab all item things
  27. $pattern = "/<item>(.*?)</item>/";
  28. preg_match_all($pattern, $buffer, $match_items, PREG_SET_ORDER);
  29. if(!empty($match_items)){
  30.   $x=0;
  31.   foreach($match_items as $matches){
  32.    //[0] includes item tags, [1] does not
  33.    //title
  34.    $pattern = "/<title>(.*?)</title>/";
  35.    preg_match($pattern, $matches[1], $match_title);
  36.    //description to determine status
  37.    $pattern = "/<description>(.*?)</description>/";
  38.    preg_match($pattern, $matches[1], $match_description);
  39.    //date
  40.    $pattern = "/<pubDate>(.*?)</pubDate>/";
  41.    preg_match($pattern, $matches[1], $match_date);
  42.    //link
  43.    $pattern = "/<link>(.*?)</link>/";
  44.    preg_match($pattern, $matches[1], $match_link);
  45.    //grab only "watching"
  46.    if(strpos($match_description[1], "Watching") !== FALSE || strpos($match_description[1], "Completed") !== FALSE){
  47.     $anime[$x]->title = $match_title[1];
  48.     $anime[$x]->status = $match_description[1];
  49.     $anime[$x]->date = $match_date[1];
  50.     $anime[$x]->link = $match_link[1];
  51.     //optional formatting - will change "title - TV - Completed - X of Y episodes" to "title - X/Y"
  52.     $anime[$x]->status = str_replace(" of ", "/", $anime[$x]->status);
  53.     $anime[$x]->status = str_replace(" episodes", "", $anime[$x]->status);
  54.     //Pre PHP 5.3
  55.      $before = explode(" - ", $anime[$x]->title);
  56.      $anime[$x]->title = $before[0];
  57.      $anime[$x]->status = strstr($anime[$x]->status, " - ");
  58.     //PHP 5.3 only
  59.      //$anime[$x]->title = strstr($anime[$x]->title, " - ", true);
  60.      //$anime[$x]->status = strstr($anime[$x]->status, " - ", false);
  61.     $anime[$x]->status = str_replace(" - ", "", $anime[$x]->status);
  62.     //increment object counter
  63.     $x++;
  64.    }
  65.   }
  66. }
  67. $image = imagecreate(600,110);
  68. $background = imagecolorallocate($image, 0,0,0);
  69. $bgtextcolor = imagecolorallocate($image, 50,50,50);
  70. $textcolor = imagecolorallocate($image, 200,200,200);
  71. $linecolor = imagecolorallocate($image, 255,0,0);
  72. // ---- scrambled text background ---- // (OPTIONAL)
  73.   $characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890~!@#$%^&*()_+-=`[]{}:;'|,.<>/?";
  74.   
  75.   for($vcntr=-1;$vcntr<60;$vcntr+=2) {
  76.    for($cntr=-1; $cntr<160; $cntr+=2){
  77.     $letter = substr($characters, rand(0,(strlen($characters)-1)),1);
  78.     
  79.     $spacing = (rand(1,10)+($cntr*4));
  80.     $vspacing = (rand(1,10)+($vcntr*4));
  81.   
  82.     imagestring($image, 5, $spacing, $vspacing, $letter, $bgtextcolor);
  83.    }
  84.   }
  85. // ---- logo image merge ---- // (OPTIONAL)
  86.   $logo = @imagecreatefromgif("http://www.sykohpath.com/images/sykohpath.gif");
  87.   if($logo){
  88.    //logo was loaded
  89.    imagecopymerge($image, $logo, 15, 12, 0, 0, 50, 50, 100);
  90.    imagerectangle($image, 15, 12, 65, 62, $linecolor);
  91.   }
  92. // ---- generic linkback ---- // (OPTIONAL)
  93.   imagestring($image, 4, 485, 90, "sykohpath.com", $linecolor);
  94. // ---- anime title status lines ---- // (REQUIRED)
  95.   for($i=0;$i<5;$i++){
  96.    if(!empty($anime[$i])){
  97.      //readability lines
  98.     imagerectangle($image, 85, ($i*16)+25, 580, ($i*16)+25, $linecolor);
  99.     imagestring($image, 5, 85,($i*16)+10, $anime[$i]->title, $textcolor);
  100.     imagestring($image, 5, 400,($i*16)+10, "(" . $anime[$i]->status . ")", $textcolor);
  101.     imagestring($image, 5, 480,($i*16)+10, date("Y M d", strtotime($anime[$i]->date)), $textcolor);
  102.    }
  103.   }
  104. // ---- border ---- // (OPTIONAL)
  105. imagesetthickness($image, 2);
  106. imagerectangle($image, 0, 1, 599, 108, $linecolor);
  107. // ---- generate the image (finally) ---- //
  108. header( "Content-type: image/png");
  109. imagepng($image);
  110. // ---- free up resources ---- //
  111. imagecolordeallocate($linecolor);
  112. imagecolordeallocate($textcolor);
  113. imagecolordeallocate($background);
  114. imagedestroy($image);
  115. ?>

php, script, myanimelist, mal,


3 comments.

tagstagstagstags
1332508617

Black Rock Shooter - TV

The last episode of Black Rock Shooter (tv) aired, and goodness, quite a ride.

I absolutely love the "other world"; great visual effects surrounded by action and fantastic designs by huke.  I've actually ordered his art book, which should be here next week - it's full of BRS designs, and comes with a figma, too!  For the other-world part of the anime, it's 10/10.

Then there is the "real world" aspect of the anime.  In looking at nothing but the reality part, we're presented with hyper-emotional girls and an apparently sadistic counselor.  In the end, everybody is happy, but the presentation just seemed to drag down the quality of the story.  Just this part is a solid 6/10.   Yeah, it wasn't as enjoyable as it should have been.

Overall, the anime is a 7/10, whatever that means.  Since it's part of the BRS world, it's impossible to avoid comparison with the OVA; the same characters are used in the same setting, with a similar story.  The OVA focused entirely on the relationship between Mato (Black Rock Shooter) and Yomi (Dead Master), and I wanted to see more of the other characters within the world.  The TV series used the other characters, which I enjoyed, but the story in the OVA I felt was stronger overall.  The character designs had some minor tweaking, although Dead Master had more of a "wedding" theme with more green; the green is better, but the outfit in the OVA felt better (not to say I didn't like the TV version).

Again, I'm anxious for the art book to see if there are other renditions of the characters.

black rock shooter, tv, anime, review,


0 comments.

tagstags
1332355000

Another

Current status: Episode 3/12

Just watched 3 episodes in a row, and was taken back by a rather nasty twist at the end of this episode.  

From the start of episode 1, we're presented with a "ghost story," and we quickly figure out what's going on.  All is fine and dandy in creepy-anime-world, and then...expectations are suddenly smashed with a hammer.  Seriously.  It was surprising enough where I had to come to this blog and do an actual anime post about it.  No spoilers, of course, but I have to say, "Another" is a rather good anime, at least for the first 3 episodes.

anime, review,


0 comments.