Get your favorite manga downloaded with Perl’s Manga Downloader 0.2

It just stupid script to download manga comic, you might want to change the website.

#!/usr/bin/perl -w
# -*- coding: utf-8 -*-
#+------------------------------------------+
#| Manga Downloader v0.2                    |
#| code by             : muffat19           |
#| bugs & suggestions  : muffat19@gmail.com |
#+ -----------------------------------------+


use LWP::Simple;
use Cwd 'chdir';

# Get title

sub get_title {
	my $base_url = get("http://www.mangapanda.com/alphabetical");
	$base_url =~ /\d+\/$ARGV[0].html/;$manga_id = "$&";
	my $base_manga = get(lc("http://mangapanda.com/$manga_id"));
	$base_manga =~ / $ARGV[1]<\/a> : \D+<\/td>/;$data = "$&";
	$data =~ s/ $ARGV[1]<\/a> : //;
	$data =~ s/<\/td>//;
	print "$data\n";
}

# loop for retrieve image

sub fetching_manga {
	$numb = 1;
	my $base_url    = get("http://mangapanda.com/$ARGV[0]/$ARGV[1]/$numb") 
		or print("invalid manga\n") and exit 0;	
	my $page_find   = '</select> of';
	my $page_search = index($base_url, $page_find);
	$parse_page 	= substr($base_url, $page_search,28);
	$parse_page 	=~ s/of..*\<\/div>\s/ /gi;$num_re = "$&\n";
	$num_re 	=~ m/(\d+)/;$page = "$&";

	# Manga found, continue for download

	print "==========================================\n";
	print "Chapter Available\n";	
	print "Manga   : $ARGV[0]\n";
	print "Chapter : $ARGV[1]\n";
	print "Title   : ";get_title;
	print "Pages   : $page\n";
	print "==========================================\n";
        print "Download this chapter [y/n]: ";$option = <STDIN>;
        chop($option);
        if (($option eq "y") || ($option eq "Y")) {
         	system("mkdir $ARGV[0]-$ARGV[1]"); } 
	else {
		exit 0; }	 
	$dir = "$ARGV[0]-$ARGV[1]";
	for ($numb = 1; $numb <= $page; $numb++) {
		my $base_img   = get("http://mangapanda.com/$ARGV[0]/$ARGV[1]/$numb");
		my $img_search = 'imgholder';
		my $result     = index($base_img, $img_search);
		$gw 	       = substr($base_img, $result,250);
		$gw 	       =~ s/http:\/\/..*\.jpg|png\s/ /gi;$img = "$&";
	if ($numb < 10) {
                chdir $dir;
		print "Saving 0$numb.jpg\n";
		getstore($img,"0$numb.jpg");
	} else {
		chdir $dir;
                print "Saving $numb.jpg\n";
		getstore($img,"$numb.jpg");
	}
	}
}

# Create parameters

$num = $#ARGV + 1; 
if ($num != 2) {
        print "Perl Manga Downloader v0.2\n";
	print "Usage : $0 manga chapter\n";
	exit 0; }
else {
	print "Checking $ARGV[0] Chapter $ARGV[1]\n";fetching_manga;
}