Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- $url=shift;
- unless ($url =~ m!https://hitomi.la/\w+/.*-(\d+)\.html$!) { die "ungültige URL"; }
- $gallid=$1;
- warn "trying to retrieve hitomi gallery $gallid\n";
- $subdom = shift;
- open(F,"wget -4nv -O - '$url'|");
- while (<F>) {
- if (m!<h1><a[^>]+>(.*)<\/a>!) {
- $title = $1;
- }
- elsif (m!href="/artist/[^>]+>(.*)</a>!) {
- push(@artist,$1);
- }
- elsif (m!href="/group/[^>]+>(.*)</a>!) {
- push(@group,$1);
- }
- elsif (m!href="/series/[^>]+>(.*)</a>!) {
- push(@series,$1) unless $1 eq 'original';
- }
- elsif (m!<td>Language</td><td><a href="/index-(\w+)-1.html!) {
- $lang=$1;
- }
- elsif (m!href="/tag/[^>]+>(.*)</a>!) {
- $tag=$1; $tag =~ s/ ♂/_M/; $tag =~ s/ ♀/_F/; $tag =~ s/ /_/g;
- push(@tag,$tag);
- }
- }
- close(F);
- open(F,"wget -4nv -O - https://ltn.hitomi.la/galleries/$gallid.js|");
- while (<F>) {
- while (s!,"hash":"(\w{61}(\w\w)(\w))","haswebp":\d,"name":"([^"]+\.(\w+))"!!) {
- # push(@imgurl,"/galleries/$gallid/$1");
- push(@imgurl,"/images/$3/$2/$1.$5");
- $rename{"$1.$5"}=$4;
- }
- }
- close(F);
- unless ($title) { die "no title extracted, wrong URL?"; }
- $name=$title;
- if (@artist) { $name .= '_'.join(",",@artist); }
- if (@group) { $name .= '('.join(",",@group).')'; }
- $name =~ s!'!'!g;
- $name =~ s!"!"!g;
- $name =~ s!&!&!g;
- $name =~ s!/!#!g;
- if (length($name)>200) {
- warn "shortening overlong name $name\n";
- $name = substr($name,0,200);
- }
- $name .= '.'.$gallid;
- if ( -e $name ) {
- die "$name exists - duplicate download request";
- }
- warn "mkdir ".$name."\n";
- mkdir ($name) && chdir ($name) || die "couldn't mkdir,chdir $name";
- warn "tags are ".join(",",@tag)."\n";
- warn "will fetch ".scalar(@imgurl)." images.\n";
- if ($lang) { warn "language is $lang\n"; }
- unless ($subdom) {
- $first = shift @imgurl;
- $subdom = 'ca';
- warn "trying subdom $subdom\n";
- system "wget -4nv --referer=https://hitomi.la/reader/$gallid.html --no-use-server-timestamps https://$subdom.hitomi.la$first";
- if ($?) {
- $subdom = 'aa';
- warn "trying subdom $subdom\n";
- system "wget -4nv --referer=https://hitomi.la/reader/$gallid.html --no-use-server-timestamps https://$subdom.hitomi.la$first";
- if ($?) {
- $subdom = 'ba';
- warn "trying subdom $subdom\n";
- system "wget -4nv --referer=https://hitomi.la/reader/$gallid.html --no-use-server-timestamps https://$subdom.hitomi.la$first";
- if ($?) {
- chdir (".."); rmdir ($name);
- die "unknown subdom";
- }
- }
- }
- }
- warn "using subdom $subdom\n";
- system "wget -4nv --referer=https://hitomi.la/reader/$gallid.html --no-use-server-timestamps ".join(" ",map { "https://$subdom.hitomi.la".$_ } @imgurl);
- foreach $f (keys(%rename)) {
- rename($f,$rename{$f});
- }
- if ($lang) { open(F,">00LANG_$lang"); close(F); }
- if (@series) { open(F,">00SERIES_".join(",",@series)); close(F); }
- while (scalar(@tag)>10) {
- open(F,">00TAGS_".join(",",splice(@tag,0,10))); close(F);
- }
- open(F,">00TAGS_".join(",",@tag)); close(F);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement