Ticket #4176: imdb.pl.diff

File imdb.pl.diff, 2.3 KB (added by mdaniels@…, 19 years ago)

Diff file for imdb.pl

  • imdb.pl

     
    387387
    388388   # If we wanted to inspect the file for any reason we can do that now
    389389
    390    #
    391    # Convert filename into a query string
    392    # (use same rules that Metadata::guesTitle does)
    393    my $query = $filename;
    394    $query = uri_unescape($query);  # in case it was escaped
     390   # The file name will be slip using 'delims' and words before anything in 'endls' will be assumed the movie's name.
     391   @delims = ("\\.","_","-"," ", "\\[", "\\]","\\(","\\)");
     392   @endls = ("dvdrip", "xvid", "divx", "dvd", "dominion", "limited", "proper", "stv", "internal", "hdrip", "cd1", "cd2", "cd3", "ws", "fs", "screener", "vcd", "svcd", "repack");
     393
    395394   # Strip off the file extension
    396    if (rindex($query, '.') != -1) {
    397       $query = substr($query, 0, rindex($query, '.'));
     395   if (rindex($filename, '.') != -1) {
     396      $filename = substr($filename, 0, rindex($filename, '.'));
    398397   }
    399    # Strip off anything following '(' - people use this for general comments
    400    if (rindex($query, '(') != -1) {
    401       $query = substr($query, 0, rindex($query, '('));
     398
     399   # IMDB searches do better if any trailing ,The is left off
     400   $filename =~ /(.*)The(.*)$/i;
     401   if ($1) { $filename = $1; }
     402   if ($2) { $filename .= $2; }
     403
     404   # replace delims with newlines for ease of spliting
     405   foreach $delim (@delims){
     406      $filename =~ s/$delim/\n/g;
    402407   }
    403    # Strip off anything following '[' - people use this for general comments
    404    if (rindex($query, '[') != -1) {
    405       $query = substr($query, 0, rindex($query, '['));
     408
     409   # split using newly added newlines
     410   @tokens = split(/\n+/, $filename);
     411
     412   # loop and build a list of words until an 'endl' is reached
     413   foreach $token (@tokens){
     414      foreach $endl (@endls){
     415         if (lc $token eq $endl){
     416            $found = 1;
     417            last;
     418         }
     419      }
     420      if ($found){
     421         last;
     422      }else{
     423           push(@words,$token);
     424      }
    406425   }
    407426
    408    # IMDB searches do better if any trailing ,The is left off
    409    $query =~ /(.*), The$/i;
    410    if ($1) { $query = $1; }
     427   # join words into an initial query
     428   $query = join "+",@words;
    411429   
    412430   # prepare the url
    413431   $query = uri_escape($query);