X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=ANN.pm;h=8b311f4b84d69f3fec2e3b292b157a6f94d1d17a;hb=5011fbe0143d3a9961cd31b8fe39783d9abe9714;hp=a9e8014a1bfbb4909136e4befbe6dd320ab1f7ef;hpb=26c14f89ca84cd6d23718948c1da81280ff12c0a;p=utils.git diff --git a/ANN.pm b/ANN.pm index a9e8014..8b311f4 100644 --- a/ANN.pm +++ b/ANN.pm @@ -35,12 +35,12 @@ sub _get $res = $ua->request(HTTP::Request->new("GET", "$uri")); if(open CACHE, ">:utf8", $cname) { - print CACHE $res->content; + print CACHE $res->decoded_content; close CACHE; } return undef unless $res->is_success; - return $res->content; + return $res->decoded_content; } sub getlist @@ -49,7 +49,7 @@ sub getlist ($name) = @_; $name = ($name =~ /^(the\s+)?(.*)$/i)[1]; - $il = uc(($name =~ /^(.)/)[0]); + $il = uc(($name =~ /^\W*(.)/)[0]); $il = "9" if (!($il =~ /[A-Z]/)); if(!($html = _get "http://www.animenewsnetwork.com/encyclopedia/anime.php?list=$il")) { return undef; @@ -74,7 +74,7 @@ sub getid ($name) = @_; $name = ($name =~ /^(the\s+)?(.*)$/i)[1]; - $il = uc(($name =~ /^(.)/)[0]); + $il = uc(($name =~ /^\W*(.)/)[0]); $il = "9" if (!($il =~ /[A-Z]/)); if(!($html = _get "http://www.animenewsnetwork.com/encyclopedia/anime.php?list=$il")) { return undef; @@ -107,7 +107,7 @@ sub getthemes if($html =~ /$kind theme:<\/strong>\s*\n/igc) { my(@parts, $ct, $buf); - while($html =~ /\G\s*\
(([^<>]|\|<\/i>)+)<\/div>/igc) { + while($html =~ /\G\s*\
(([^<>]|\|<\/i>)+)(]*>[^<>]*]*>[^<>]*<\/span>)?<\/div>/igc) { $buf = $1; # 0 1 2 3 4 5 6 7 8 9 10 1112 if(@parts = ($buf =~ /(\#(\d+):)?\s*\"([^\"\(]+\S)(\s*\((\(.*)<\/i>( - \s*)?)?([^<>]+)?\))?\"\s+by\s+([^\(]*[^\(\s])(\s*\(eps? (\d+)(-(\d+))?\))?/i)) {