Index: imdb.pl
===================================================================
--- imdb.pl	(revision 14868)
+++ imdb.pl	(working copy)
@@ -387,27 +387,45 @@
 
    # If we wanted to inspect the file for any reason we can do that now
 
-   #
-   # Convert filename into a query string 
-   # (use same rules that Metadata::guesTitle does)
-   my $query = $filename;
-   $query = uri_unescape($query);  # in case it was escaped
+   # The file name will be slip using 'delims' and words before anything in 'endls' will be assumed the movie's name.
+   @delims = ("\\.","_","-"," ", "\\[", "\\]","\\(","\\)");
+   @endls = ("dvdrip", "xvid", "divx", "dvd", "dominion", "limited", "proper", "stv", "internal", "hdrip", "cd1", "cd2", "cd3", "ws", "fs", "screener", "vcd", "svcd", "repack");
+
    # Strip off the file extension
-   if (rindex($query, '.') != -1) {
-      $query = substr($query, 0, rindex($query, '.'));
+   if (rindex($filename, '.') != -1) {
+      $filename = substr($filename, 0, rindex($filename, '.'));
    }
-   # Strip off anything following '(' - people use this for general comments
-   if (rindex($query, '(') != -1) {
-      $query = substr($query, 0, rindex($query, '(')); 
+
+   # IMDB searches do better if any trailing ,The is left off
+   $filename =~ /(.*)The(.*)$/i;
+   if ($1) { $filename = $1; }
+   if ($2) { $filename .= $2; }
+
+   # replace delims with newlines for ease of spliting
+   foreach $delim (@delims){
+      $filename =~ s/$delim/\n/g;
    }
-   # Strip off anything following '[' - people use this for general comments
-   if (rindex($query, '[') != -1) {
-      $query = substr($query, 0, rindex($query, '[')); 
+
+   # split using newly added newlines
+   @tokens = split(/\n+/, $filename);
+
+   # loop and build a list of words until an 'endl' is reached
+   foreach $token (@tokens){
+      foreach $endl (@endls){
+         if (lc $token eq $endl){
+            $found = 1;
+            last;
+         }
+      }
+      if ($found){
+         last;
+      }else{
+   	   push(@words,$token);
+      }
    }
 
-   # IMDB searches do better if any trailing ,The is left off
-   $query =~ /(.*), The$/i;
-   if ($1) { $query = $1; }
+   # join words into an initial query
+   $query = join "+",@words;
    
    # prepare the url 
    $query = uri_escape($query);
