xmltv/lib IMDB.pm,1.58,1.59

Jerry Veldhuis <[email protected]>
Newsgroups gmane.comp.tv.xmltv.cvs
Message-ID <[email protected]>
Update of /cvsroot/xmltv/xmltv/lib
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23834/lib

Modified Files:
	IMDB.pm 
Log Message:
feature request 104 - download progress. also updated list file size estimates

Index: IMDB.pm
===================================================================
RCS file: /cvsroot/xmltv/xmltv/lib/IMDB.pm,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** IMDB.pm	6 May 2013 03:09:34 -0000	1.58
--- IMDB.pm	16 Dec 2013 01:38:58 -0000	1.59
***************
*** 1244,1248 ****
  
  package XMLTV::IMDB::Crunch;
! use LWP::Simple;
  
  # Use Term::ProgressBar if installed.
--- 1244,1248 ----
  
  package XMLTV::IMDB::Crunch;
! use LWP;
  
  # Use Term::ProgressBar if installed.
***************
*** 1331,1335 ****
      }
      if ( $self->{downloadMissingFiles} ) {
! 	my $baseUrl = 'ftp://ftp.fu-berlin.de/pub/misc/movies/database/';
  	foreach ( sort keys %missingListFiles ) {
  	    my $url = "$baseUrl/$_.list.gz";
--- 1331,1335 ----
      }
      if ( $self->{downloadMissingFiles} ) {
! 	my $baseUrl = 'ftp://ftp.fu-berlin.de/pub/misc/movies/database';
  	foreach ( sort keys %missingListFiles ) {
  	    my $url = "$baseUrl/$_.list.gz";
***************
*** 1359,1368 ****
  END
    ;
! 	    # For downloading we use LWP::Simple::getstore() to write
! 	    # to a file.
  	    #
! 	    my $resp = getstore($url, $filename);
  	    my $got_size = -s $filename;
! 	    if (defined $resp and is_success($resp)) {
  		die if not $got_size;
  		print STDERR "<$url>\n\t-> $filename, success\n\n";
--- 1359,1374 ----
  END
    ;
! 	    # For downloading we use LWP
  	    #
! 	    my $ua = LWP::UserAgent->new();
! 	    $ua->env_proxy();
! 	    $ua->show_progress(1);
! 
! 	    my $req = HTTP::Request->new(GET => $url);
! 	    $req->authorization_basic('anonymous', 'tv_imdb');
! 
! 	    my $resp = $ua->request($req, $filename);
  	    my $got_size = -s $filename;
! 	    if (defined $resp and $resp->is_success ) {
  		die if not $got_size;
  		print STDERR "<$url>\n\t-> $filename, success\n\n";
***************
*** 1370,1374 ****
  	    else {
  		my $msg = "failed to download $url to $filename";
! 		$msg .= ", http response code: $resp" if defined $resp;
  		warn $msg;
  		if ($got_size) {
--- 1376,1380 ----
  	    else {
  		my $msg = "failed to download $url to $filename";
! 		$msg .= ", http response code: ".$resp->status_line if defined $resp;
  		warn $msg;
  		if ($got_size) {
***************
*** 1954,1958 ****
      if ( $stage == 1 ) {
  	$self->status("parsing Movies list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("movies", 43);
  
  	my $num=$self->readMoviesOrGenres("Movies", $countEstimate, "$self->{imdbListFiles}->{movies}");
--- 1960,1964 ----
      if ( $stage == 1 ) {
  	$self->status("parsing Movies list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("movies", 47);
  
  	my $num=$self->readMoviesOrGenres("Movies", $countEstimate, "$self->{imdbListFiles}->{movies}");
***************
*** 2005,2009 ****
  	$self->status("parsing Directors list for stage $stage..");
  
! 	my $countEstimate=$self->dbinfoCalcEstimate("directors", 225);
  
  	my $num=$self->readCastOrDirectors("Directors", $countEstimate, "$self->{imdbListFiles}->{directors}");
--- 2011,2015 ----
  	$self->status("parsing Directors list for stage $stage..");
  
! 	my $countEstimate=$self->dbinfoCalcEstimate("directors", 258);
  
  	my $num=$self->readCastOrDirectors("Directors", $countEstimate, "$self->{imdbListFiles}->{directors}");
***************
*** 2072,2076 ****
  
  	#print "re-reading movies into memory for reverse lookup..\n";
! 	my $countEstimate=$self->dbinfoCalcEstimate("actors", 415);
  
  	my $num=$self->readCastOrDirectors("Actors", $countEstimate, "$self->{imdbListFiles}->{actors}");
--- 2078,2082 ----
  
  	#print "re-reading movies into memory for reverse lookup..\n";
! 	my $countEstimate=$self->dbinfoCalcEstimate("actors", 449);
  
  	my $num=$self->readCastOrDirectors("Actors", $countEstimate, "$self->{imdbListFiles}->{actors}");
***************
*** 2123,2127 ****
  	$self->status("parsing Actresses list for stage $stage..");
  
! 	my $countEstimate=$self->dbinfoCalcEstimate("actresses", 382);
  	my $num=$self->readCastOrDirectors("Actresses", $countEstimate, "$self->{imdbListFiles}->{actresses}");
  	if ( $num < 0 ) {
--- 2129,2133 ----
  	$self->status("parsing Actresses list for stage $stage..");
  
! 	my $countEstimate=$self->dbinfoCalcEstimate("actresses", 483);
  	my $num=$self->readCastOrDirectors("Actresses", $countEstimate, "$self->{imdbListFiles}->{actresses}");
  	if ( $num < 0 ) {
***************
*** 2172,2176 ****
      elsif ( $stage == 5 ) {
  	$self->status("parsing Genres list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("genres", 61);
  
  	my $num=$self->readMoviesOrGenres("Genres", $countEstimate, "$self->{imdbListFiles}->{genres}");
--- 2178,2182 ----
      elsif ( $stage == 5 ) {
  	$self->status("parsing Genres list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("genres", 68);
  
  	my $num=$self->readMoviesOrGenres("Genres", $countEstimate, "$self->{imdbListFiles}->{genres}");
***************
*** 2222,2226 ****
      elsif ( $stage == 6 ) {
  	$self->status("parsing Ratings list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("ratings", 63);
  
  	my $num=$self->readRatings($countEstimate, "$self->{imdbListFiles}->{ratings}");
--- 2228,2232 ----
      elsif ( $stage == 6 ) {
  	$self->status("parsing Ratings list for stage $stage..");
! 	my $countEstimate=$self->dbinfoCalcEstimate("ratings", 68);
  
  	my $num=$self->readRatings($countEstimate, "$self->{imdbListFiles}->{ratings}");


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.