Author: duncan
Date: Tue Jul 31 17:27:50 2007
New Revision: 9784

Log:
Fixes for imdb search when the name contains numbers only


Modified:
   branches/rel-1/freevo/freevo_config.py
   branches/rel-1/freevo/setup.py
   branches/rel-1/freevo/src/helpers/imdb.py
   branches/rel-1/freevo/src/util/fxdimdb.py

Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py      (original)
+++ branches/rel-1/freevo/freevo_config.py      Tue Jul 31 17:27:50 2007
@@ -696,8 +696,8 @@
 # list of regexp to be ignored on a disc label
 IMDB_REMOVE_FROM_LABEL = ('season[\._ -][0-9]+', 'disc[\._ -][0-9]+',
                           'd[\._ -][0-9]+', 'german')
-# list of regexp to be ignored on a filename
-IMDB_REMOVE_FROM_NAME = ['^[0-9_]+']
+# list of regexp to be ignored on a filename, match TV_RECORDMASK
+IMDB_REMOVE_FROM_NAME = ['^[0-9]+-[0-9]+[ _][0-9]+\.[0-9]+[ _]']
 
 # list of words to ignore when searching based on a filename
 IMDB_REMOVE_FROM_SEARCHSTRING = ('the', 'a')

Modified: branches/rel-1/freevo/setup.py
==============================================================================
--- branches/rel-1/freevo/setup.py      (original)
+++ branches/rel-1/freevo/setup.py      Tue Jul 31 17:27:50 2007
@@ -44,7 +44,7 @@
 
     def initialize_options (self):
         pass
-    
+
     def finalize_options (self):
         pass
 
@@ -93,7 +93,7 @@
                     # the normal one doesn't work
                     continue
                 os.system('mv "%s" "%s"' % (source, dest))
-        
+
     def run (self):
         """
         download and install the runtime + current mmpython
@@ -110,7 +110,7 @@
         os.path.walk('mmpython-%s' % version.mmpython, self.mmpython_install, 
None)
         os.system('rm -rf mmpython-%s' % version.mmpython)
 
-    
+
 # check if everything is in place
 if (len(sys.argv) < 2 or sys.argv[1].lower() not in ('i18n', '--help', 
'--help-commands')):
     if os.path.isdir('.svn'):

Modified: branches/rel-1/freevo/src/helpers/imdb.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/imdb.py   (original)
+++ branches/rel-1/freevo/src/helpers/imdb.py   Tue Jul 31 17:27:50 2007
@@ -144,10 +144,14 @@
             usage()
 
         filename = search_arg
-        print "searching " + filename
-        for result in fxd.searchImdb(filename):
+        print "Searching IMDB for '%s'..." % filename
+        results = fxd.searchImdb(filename)
+        _debug_('%r' % results)
+        if len(results) == 0:
+            print 'No results'
+        for result in results:
             if result[3]:
-                print '%s   %s (%s, %s)' % result
+                print '%s   %s (%s) %s' % result
             else:
                 print '%s   %s (%s)' % (result[0], result[1], result[2])
         sys.exit(0)
@@ -155,10 +159,14 @@
 
     if task == 'guess':
         filename = search_arg
-        print "searching " + filename
-        for result in fxd.guessImdb(filename):
+        print "Searching IMDB for '%s'..." % filename
+        results = fxd.guessImdb(filename)
+        if len(results) == 0:
+            print 'No results'
+        _debug_('%r' % results)
+        for result in results:
             if result[3]:
-                print '%s   %s (%s, %s)' % result
+                print '%s   %s (%s) %s' % result
             else:
                 print '%s   %s (%s)' % (result[0], result[1], result[2])
         sys.exit(0)

Modified: branches/rel-1/freevo/src/util/fxdimdb.py
==============================================================================
--- branches/rel-1/freevo/src/util/fxdimdb.py   (original)
+++ branches/rel-1/freevo/src/util/fxdimdb.py   Tue Jul 31 17:27:50 2007
@@ -129,8 +129,9 @@
         Search for name and returns an id list with tuples:
             (id , name, year, type)"""
 
-        url = 'http://us.imdb.com/Tsearch?title=%s&restrict=Movies+and+TV' % 
urllib.quote(name)
-        url = 'http://www.imdb.com/find?s=tt;site=aka;q=%s' % 
urllib.quote(name)
+        _debug_('searching imdb for "%s"' % (name))
+        url = 'http://us.imdb.com/Tsearch?title=%s&restrict=Movies+and+TV' % 
urllib.quote(str(name))
+        url = 'http://www.imdb.com/find?s=tt;site=aka;q=%s' % 
urllib.quote(str(name))
         _debug_('url="%s"' % (url))
 
         req = urllib2.Request(url, txdata, txheaders)
@@ -142,8 +143,7 @@
             raise FxdImdb_Net_Error("IMDB unreachable : " + error)
             return None
 
-        if config.DEBUG:
-            _debug_('response.url="%s"' % (response.geturl()))
+        _debug_('response.url="%s"' % (response.geturl()))
 
         m=re.compile('/title/tt([0-9]*)/')
         idm = m.search(response.geturl())
@@ -154,15 +154,17 @@
         data = self.parsesearchdata(response)
         response.close()
 
+        _debug_('imdb_id_list has %s items' % (len(self.imdb_id_list)))
         if len(self.imdb_id_list) > 20:
-            # too much results, check if there are stupid results in the
-            # list
+            # too many results, check if there are stupid results in the list
             words = []
 
             # make a list of all words (no numbers) in the search string
             for p in re.split('[\._ -]', searchstring):
-                if p and not p[0] in '0123456789':
-                    words.append(p)
+                #XXX this is incorrect for number only searches
+                #if p and not p[0] in '0123456789':
+                #    words.append(p)
+                words.append(p)
 
             # at least one word has to be in the result
             new_list = []
@@ -174,6 +176,7 @@
                         new_list.append(result)
                         appended = True
             self.imdb_id_list = new_list
+            _debug_('imdb_id_list has now %s items' % (len(self.imdb_id_list)))
         return self.imdb_id_list
 
 
@@ -666,7 +669,8 @@
             #print item.parent.findChildren(text=re.compile('[^ ]'))
             self.imdb_id_list += [ ( id, name, year, type ) ]
 
-        _debug_(self.imdb_id_list)
+        for item in self.imdb_id_list:
+            _debug_('%r' % (item,), 2)
         return self.imdb_id_list
 
     def findepisode(self, results):
@@ -793,7 +797,7 @@
             for (k,v) in self.info.items():
                 _debug_('items=%s:%s' % (k, v))
             _debug_('id="%s", dvd="%s"' % (id, dvd))
-            _debug_(self.info)
+            _debug_(self.info, 2)
 
         # Add impawards.com poster URLs.
         self.impawardsimages(self.info['title'], self.info['year'])

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to