Index: imdb.pl
===================================================================
--- imdb.pl	(revision 8870)
+++ imdb.pl	(working copy)
@@ -15,7 +15,13 @@
 #     - when searching amazon, try searching for main movie name and if nothing is found, search for informal name
 #     - better handling for amazon posters, see if movie title is a substring in the search results returned by amazon
 #     - fixed redirects for some movies on impawards
+# v1.3
+#     - added a valid amazon service developer id for amazon searches (registered to arjeousski@gmail.com)
+#     - fixed search for low res images (imdb changed the page layout)
+#     - added cinemablend poster search
+#     - added nexbase poster search
 
+
 use LWP::Simple;      # libwww-perl providing simple HTML get actions
 use HTML::Entities;
 use URI::Escape;
@@ -26,7 +32,7 @@
 use Getopt::Std; 
 
 $title = "IMDB Query"; 
-$version = "v1.2";
+$version = "v1.3";
 $author = "Tim Harvey, Andrei Rjeousski";
 
 # display usage
@@ -240,6 +246,7 @@
 
    my $uri = "";
 
+
    # look for references to impawards.com posters - they are high quality
    my $site = "http://www.impawards.com";
    my $impsite = parseBetween($response, "<a href=\"".$site, "\">".$site);
@@ -275,6 +282,42 @@
       if (defined $opt_d) { print "# found ipmawards poster: $uri\n"; }
    }
 
+   # try looking on nexbase
+   if ($uri eq "" && $response =~ m/<a href="([^"]*)">([^"]*?)nexbase/i) {
+        if ($1 ne "") {
+           if (defined $opt_d) { print "# found nexbase poster page: $1 \n"; }
+           my $cinres = get $1;
+           if (defined $opt_d) { printf("# got %i bytes\n", length($cinres)); }
+           if (defined $opt_r) { printf("%s", $cinres); }
+
+           if ($cinres =~ m/<a id="photo_url" href="([^"]*?)" ><\/a>/i) {
+               if (defined $opt_d) { print "# nexbase url retreived\n"; }
+               $uri = $1;
+           }
+
+        }
+
+   }
+
+
+
+   # try looking on cinemablend
+   if ($uri eq "" && $response =~ m/<a href="([^"]*)">([^"]*?)cinemablend/i) {
+	if ($1 ne "") {
+           if (defined $opt_d) { print "# found cinemablend poster page: $1 \n"; }
+	   my $cinres = get $1;
+           if (defined $opt_d) { printf("# got %i bytes\n", length($cinres)); }
+           if (defined $opt_r) { printf("%s", $cinres); }
+
+           if ($cinres =~ m/<td align=center><img src="([^"]*?)" border=1><\/td>/i) {
+               if (defined $opt_d) { print "# cinemablend url retreived\n"; }
+               $uri = "http://www.cinemablend.com/".$1;   
+           }
+
+ 	}
+
+   }
+
    # if the impawards site attempt didn't give a filename grab it from imdb
    if ($uri eq "") {
        if (defined $opt_d) { print "# looking for imdb posters\n"; }
@@ -287,22 +330,33 @@
           if (defined $opt_d) { print "# no poster found\n"; }
        }
    }
-   
-   # now we couldnt even find lowres poster from IMDB, lets try looking for dvd
-   # cover on amazon.com   
 
+
+
    my @movie_titles;
    my $found_low_res = 0;
    my $k = 0;
    
    # no poster found, take lowres image from imdb
    if ($uri eq "") {
-       if (defined $opt_d) { print "# looking for lowres imdb posters\n"; }
-       my $host = "http://www.imdb.com/title/tt" . $movieid . "/";
-       $response = get $host;
+      if (defined $opt_d) { print "# looking for lowres imdb posters\n"; }
+      my $host = "http://www.imdb.com/title/tt" . $movieid . "/";
+      $response = get $host;
 
-       $uri = parseBetween($response, "alt=\"cover\" src=\"http://ia.imdb.com/media/imdb/", "\"");
-       
+      # Better handling for low resolution posters
+      # 
+      if ($response =~ m/<a name="poster".*<img.*src="([^"]*).*<\/a>/ig) {
+           if (defined $opt_d) { print "# found low res poster at: $1\n"; }
+           $uri = $1;
+           $found_low_res = 1;
+
+      } else {
+          if (defined $opt_d) { print "# no low res poster found\n"; }
+	  $uri = "";
+      }
+ 
+
+
       if (defined $opt_d) { print "# starting to look for movie title\n"; }
       
       # get main title
@@ -319,12 +373,6 @@
          if (defined $opt_d) { print "# Title: ".$movie_titles[$k-1]."\n"; }
       }
        
-       if ($uri ne "" ) {
-           $uri = "http://ia.imdb.com/media/imdb/".$uri;
-           $found_low_res = 1;
-       } else {
-          if (defined $opt_d) { print "# no poster found\n"; }
-       }
    }
    
    # now we couldnt even find lowres poster from IMDB, lets try looking for dvd
@@ -338,6 +386,7 @@
       my $xml_parser = XML::Simple->new();
       
          
+      # loop through all titles
       do {
          # get rid of the year
          $movie_titles[$titleid] =~ s/ ?\([^\)]+\) ?//g;
@@ -352,7 +401,8 @@
          my $safe_movie_title = $movie_titles[$titleid];
          $safe_movie_title =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;      
          # request XML info from amazon
-         my $xml_uri = "http://xml.amazon.com/onca/xml3?t=000&dev-t=000&KeywordSearch=".$safe_movie_title."&mode=dvd&type=lite&page=1&f=xml";
+	 # Amazon DEV_t is from Andrei Rjeousski (arjeousski at gmail.com)
+         my $xml_uri = "http://xml.amazon.com/onca/xml3?t=000&dev-t=0TJR5CSZSS2KE77KWKG2&KeywordSearch=".$safe_movie_title."&mode=dvd&type=lite&page=1&f=xml";
          if (defined $opt_d) { print "# Amazon request string is: $xml_uri\n";}
 
          # get the response
