X-Git-Url: http://dolda2000.com/gitweb/?p=utils.git;a=blobdiff_plain;f=anndl;fp=anndl;h=c62c8c13edeb882738f5c2027a4d3fdb8ac745d6;hp=0000000000000000000000000000000000000000;hb=29c59b44c18917a17e6eaeba69ee60fe87a6986c;hpb=f833b96c824951ebeae446977dd12b3eb03b77e6 diff --git a/anndl b/anndl new file mode 100755 index 0000000..c62c8c1 --- /dev/null +++ b/anndl @@ -0,0 +1,68 @@ +#!/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"; +}