#!/usr/bin/perl -w use Anime::ANN; use Getopt::Long qw/:config gnu_getopt/; if(!defined($ARGV[0])) { print STDERR "usage: anndl SERIES\n"; exit 1; } unless($id = Anime::ANN::getid $ARGV[0]) { print STDERR "anndl: could not find $ARGV[0]\n"; exit 1; } %info = %{Anime::ANN::getseries $id}; if(!defined $info{"eps"}) { print "could not find number of eps\n"; print "accept? "; if(!( =~ /^y/i)) { exit 1; } } $name = $info{"name"}; print "canonical name [$name]: "; chomp($newname = ); $name = $newname if $newname ne ""; $dirname = $ENV{"HOME"} . "/dc/autodl/cur/" . $name; mkdir $dirname || die "could not create $dirname: $!"; mkdir "$dirname/.autodl" || die "could not create $dirname/.autodl: $!"; open FH, ">$dirname/.autodl/disabled" || die "could not create $dirname/.autodl/disabled: $!"; close FH; open FH, ">$dirname/nextep" || die "could not create nextep: $!"; print FH "1\n"; close FH; open FH, ">$dirname/.autodl/uarg" || die "could not create $dirname/.autodl/uarg: $!"; if(defined $info{"eps"}) { $melen = length $info{"eps"} } else { $melen = 2; } print FH ("rename:auto:$name:$melen:move:../autodl/cur/$name\n"); close FH; $sexpr = lc $name; $sexpr =~ s/ /.*/g; $sexpr = "\"L~$sexpr\[^0-9]*0*%i([^0-9]*(\\[[^]]*\\]|\\([^\\)]*\\)|v2))*[^0-9]*\\.(avi|ogm|mkv|mp4)\$\""; open FH, ">$dirname/.autodl/sexpr" || die "could not create $dirname/.autodl/sexpr: $!"; print FH "$sexpr\n"; close FH; print "sexpr: $sexpr\n"; print "accept? "; if(!( =~ /^y/i)) { system $ENV{"EDITOR"}, "$dirname/.autodl/sexpr"; } open FH, ">$dirname/.autodl/curep" || die "could not create $dirname/.autodl/curep: $!"; print FH "1\n"; close FH; if(defined $info{"eps"}) { open FH, ">$dirname/.autodl/maxep" || die "could not create $dirname/.autodl/maxep: $!"; print FH ($info{"eps"} . "\n"); close FH; } print "begin? "; if( =~ /^y/i) { unlink "$dirname/.autodl/disabled"; }