Programma perl per scaricare files pod
Programma perl che legge ed estrae dalla pagina web: http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod i nomi dei file pod disponibili sul sito e li scarica localmente


name

FILE: downloadBBC.pl
Ultimo aggiornamneto: 02.08.2007


description

Scarica gli ultimi radiogiornali in formato file POD dal sito della BBC


detailed description


il programma legge la pagina web:
http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod
da cui estrae i nomi dei file pod disponibili, che provvede a scaricare localmente


sample of running program

[enzo@enzo6 perl_proj1]$ ./downloadBBC.pl [2007.1.5 18:51:33] Inizio ./downloadBBC.pl


[2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070104.mp3 already exists
[2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070103.mp3 already exists
[2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3 already exists
[2007.1.5 18:51:34] Fine ./downloadBBC.pl


[enzo@enzo6 perl_proj1]$ rm /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3
[enzo@enzo6 perl_proj1]$ ./downloadBBC.pl
[2007.1.5 18:51:57] Inizio ./downloadBBC.pl


[2007.1.5 18:51:57] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070104.mp3 already exists
[2007.1.5 18:51:57] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070103.mp3 already exists
[2007.1.518:51:57] =================


[2007.1.5 18:51:57] LINK(1):http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod/bbcradionewspod_20070102-1800_40_pc.mp3 --> MP3:/usr_data/DOWNLOAD/BBC/bbc_20070102.mp3
[2007.1.5 18:53:35] STATUS(200) copy from http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod/bbcradionewspod_20070102-1800_40_pc.mp3 to /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3
[2007.1.5 18:53:35] Fine ./downloadBBC.pl



   1    #!/usr/bin/perl    2    # {|}~     3    # FILE: downloadBBC.pl    4    # ultimo aggiornamneto: 02.08.2007    5    # =====================================    6        7        8    use strict;    9    use LWP::Simple;   10       11    =head1 name   12       13     FILE: downloadBBC.pl   14     ultimo aggiornamneto: 02.08.2007   15       16    =head1 description   17       18       Scarica gli ultimi radiogiornali in formato file POD dal sito della BBC   19       20    =head2 detailed description   21       22      il programma legge la pagina web:   23       http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod   24       da cui estrae i nomi dei file pod disponibili, che provvede a scaricare   25       localmente   26       27       28          29    =head2 sample of running program      30       31    [enzo@enzo6 perl_proj1]$ ./downloadBBC.pl   32    [2007.1.5 18:51:33]  Inizio ./downloadBBC.pl   33       34    [2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070104.mp3 already exists   35    [2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070103.mp3 already exists   36    [2007.1.5 18:51:34] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3 already exists   37    [2007.1.5 18:51:34]  Fine ./downloadBBC.pl   38       39    [enzo@enzo6 perl_proj1]$ rm /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3   40    [enzo@enzo6 perl_proj1]$ ./downloadBBC.pl   41    [2007.1.5 18:51:57]  Inizio ./downloadBBC.pl   42       43    [2007.1.5 18:51:57] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070104.mp3 already exists   44    [2007.1.5 18:51:57] [SKIPPED DOWNLOAD] file /usr_data/DOWNLOAD/BBC/bbc_20070103.mp3 already exists   45    [2007.1.5 18:51:57] =================   46       47    [2007.1.5 18:51:57] LINK(1):http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod/bbcradionewspod_200701         02-1800_40_pc.mp3 --> MP3:/usr_data/DOWNLOAD/BBC/bbc_20070102.mp3   48    [2007.1.5 18:53:35] STATUS(200) copy from http://downloads.bbc.co.uk/rmhttp/downloadtrial/radionews/bbcradionewspod/bbcradio         newspod_20070102-1800_40_pc.mp3 to /usr_data/DOWNLOAD/BBC/bbc_20070102.mp3   49    [2007.1.5 18:53:35]  Fine ./downloadBBC.pl   50       51    =cut   52       53       54       55    my ( $body, $stmp, $stmp1, $stmp2, $link, $sel_link, $cnt );   56       57    my $src_html_url = 'http://www.bbc.co.uk/radio/podcasts/newspod/';   58    my $dest_dir = '/usr_data/DOWNLOAD/BBC/';   59       60    mylog (" Inizio $0 \n" );   61       62    $body = get $src_html_url;   63    die "ERRORE download $src_html_url ( $! ) \n\n" unless defined $body;   64       65    my @alink = split '.mp3', $body;   66       67    my $check1 = 'http://downloads.bbc.co.uk/podcasts/radio/newspod/';   68    my $check2 = 'newspod';   69       70    # href="http://downloads.bbc.co.uk/podcasts/radio/newspod/newspod_20070802-1900.mp3"   71       72    $cnt = 1;   73    foreach $link  ( @alink )   74    {   75        if( $link =~ m/${check2}_/ )   76        {   77            $link .= '.mp3';   78            my ( $t1, $t2 ) = $link =~ m/(${check1}${check2}_.*)-(.*)/;   79            my ( $local_mp3_file ) = $t1 =~ m/(${check2}_.*)/;   80            $local_mp3_file =~ s/${check2}/bbc/;   81            $local_mp3_file = "${dest_dir}${local_mp3_file}.mp3";   82            if( -f $local_mp3_file )   83            {   84                mylog( "[SKIPPED DOWNLOAD] file $local_mp3_file already exists " );   85                next;   86            }   87            $sel_link = "${t1}-${t2}";   88            mylog( "=================\n" );   89            mylog(  "LINK($cnt):$sel_link --> MP3:$local_mp3_file" );   90            $cnt++;   91            my $sret = getstore( $sel_link, $local_mp3_file );   92            mylog(  "STATUS($sret) copy from $sel_link to $local_mp3_file" );   93        }   94    }   95       96    mylog ( " Fine $0 \n" );   97       98    # ==================================   99    # ==================================  100    sub mylog  101    {  102        my ( $mymsg ) = @_;  103        my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( time() );  104        $year += 1900;  105        $mon  += 1;  106        my $mytime = "$year\.$mon\.$mday $hour:$min:$sec";  107        print "[$mytime] $mymsg \n";  108    }