Thursday, April 8, 2010

jw.org download script

#!/usr/bin/perl 

our @GREEK_SCRIPTURES = qw/Mt Mr Lu Joh Ac Ro 1Co 2Co Ga Eph Php Col 1Th 2Th 1Ti 2Ti Tit Phm Heb Jas 1Pe 2Pe 1Jo 2Jo 3Jo Jude Re/;
our @GREEK_CHAPTERS = qw/28 16 24 21 28 16 16 13 6 6 4 3 5 3 6 4 3 1 13 5 5 3 5 3 1 1 22/;

my $i = 40;
my $x = 0;
foreach my $abbrev (@GREEK_SCRIPTURES) {
   for ( 1 .. $GREEK_CHAPTERS[$x] ) {
      if ($ARGV[0]) {
         next unless ($ARGV[0] and $ARGV[0] =~ /$abbrev/);
      }
      $file = sprintf "%d_%s_ASL_%02d.m4v", $i, $abbrev, $_;
      next if -e $file;
      $url = sprintf "http://download.jw.org/files/media_bible/%s\n", $file;
      print $url, "\n";
      #system("wget -nc $url");
      system("curl -O $url");
      system("rm $file") if $! =~ /No such/;
   }
   $x++;
   $i++;
}

No comments:

Post a Comment