diff options
| -rwxr-xr-x | bin/comirror | 27 | ||||
| -rwxr-xr-x | bin/comirror-setup | 2 | 
2 files changed, 23 insertions, 6 deletions
| diff --git a/bin/comirror b/bin/comirror index 8a9528b..b5e20ab 100755 --- a/bin/comirror +++ b/bin/comirror @@ -12,6 +12,7 @@ my $mech = WWW::Mechanize->new(  my $uri      = shift || first_line('last_uri');  my $image_re = first_line('image_re');  my $exit     = 1; +my $next_link_text;  if (not defined $uri or not defined $image_re) {  	die("last_uri or image_re not found / specified\n"); @@ -19,17 +20,31 @@ if (not defined $uri or not defined $image_re) {  $image_re = qr{$image_re}; +if (-e 'next_link') { +	$next_link_text = first_line('next_link'); +} +  sub find_next_link { -	foreach my $re ( -		qr{ ^ next $ }ix, -		qr{   next   }ix, -	) -	{ -		my $link = $mech->find_link(text_regex => $re); + +	if (defined $next_link_text) { +		my $link = $mech->find_link(text => $next_link_text);  		if ($link) {  			return $link;  		}  	} +	else { + +		foreach my $re ( +			qr{ ^ next $ }ix, +			qr{   next   }ix, +		) +		{ +			my $link = $mech->find_link(text_regex => $re); +			if ($link) { +				return $link; +			} +		} +	}  	save_lasturi();  	say "Cannot find next link. We might have reached the end of the comic.";  	exit $exit; diff --git a/bin/comirror-setup b/bin/comirror-setup index 05661bf..f5d4c76 100755 --- a/bin/comirror-setup +++ b/bin/comirror-setup @@ -39,6 +39,7 @@ print "\nComparing images";  for my $i ( 0 .. $#mechs ) {  	for my $image ($mechs[$i]->find_all_images()) {  		push(@{$images[$i]}, $image->url_abs()); +		say "$i $images[$i]->[-1]";  	}  	print q{.};  } @@ -94,6 +95,7 @@ for my $offset ( 0 .. $length ) {  line_to_file($ARGV[0], 'last_uri');  line_to_file($image_re, 'image_re'); +line_to_file($next_link, 'next_link');  print "\nimage_re: ${image_re}\n\n";  say "\"next\" link text: ${next_link}"; | 
