Update of /cvsroot/freevo/freevo/src/video
In directory sc8-pr-cvs1:/tmp/cvs-serv16639

Modified Files:
        fxdimdb.py 
Log Message:
smarter search

Index: fxdimdb.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/fxdimdb.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** fxdimdb.py  23 Aug 2003 12:51:43 -0000      1.7
--- fxdimdb.py  27 Aug 2003 19:24:08 -0000      1.8
***************
*** 12,15 ****
--- 12,18 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.8  2003/08/27 19:24:08  dischi
+ # smarter search
+ #
  # Revision 1.7  2003/08/23 12:51:43  dischi
  # removed some old CVS log messages
***************
*** 155,159 ****
                urllib.quote(name)
          req = urllib2.Request(url, txdata, txheaders)
!     
          try:
              response = urllib2.urlopen(req)
--- 158,163 ----
                urllib.quote(name)
          req = urllib2.Request(url, txdata, txheaders)
!         searchstring = name
!         
          try:
              response = urllib2.urlopen(req)
***************
*** 173,177 ****
              self.imdb_id_list = [ ( m.group(1), data[0], data[1]['year'], '' ) ]
              return self.imdb_id_list
!         
          for line in response.read().split("\n"):
              m = regexp_type.match(line)
--- 177,181 ----
              self.imdb_id_list = [ ( m.group(1), data[0], data[1]['year'], '' ) ]
              return self.imdb_id_list
! 
          for line in response.read().split("\n"):
              m = regexp_type.match(line)
***************
*** 195,201 ****
                      year = year[:year.find(')')]
      
!                 for i in range(len(self.imdb_id_list)):
!                     if self.imdb_id_list == id:
!                         self.imdb_id_list = ( id , name, year, type )
                          break
                  else:
--- 199,204 ----
                      year = year[:year.find(')')]
      
!                 for i in self.imdb_id_list:
!                     if i[0] == id:
                          break
                  else:
***************
*** 203,206 ****
--- 206,227 ----
          
          response.close()
+         if len(self.imdb_id_list) > 20:
+             # too much 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)
+ 
+             # at least one word has to be in the result
+             new_list = []
+             for result in self.imdb_id_list:
+                 for search_word in words:
+                     if result[1].lower().find(search_word.lower()) != -1:
+                         new_list.append(result)
+             self.imdb_id_list = new_list
+ 
          return self.imdb_id_list
      
***************
*** 392,407 ****
          name  = re.sub('([a-zA-Z])([0-9])', point_maker, name)
          name  = re.sub('([0-9])([a-zA-Z])', point_maker, name.lower())
!         
          if label == TRUE:
              for r in config.IMDB_REMOVE_FROM_LABEL:
                  name  = re.sub(r, '', name)
!         
          parts = re.split('[\._ -]', name)
-         
          name = ''
          for p in parts:
!             if not p.lower() in config.IMDB_REMOVE_FROM_SEARCHSTRING:
                  name += '%s ' % p
- 
          return self.searchImdb(name)
  
--- 413,427 ----
          name  = re.sub('([a-zA-Z])([0-9])', point_maker, name)
          name  = re.sub('([0-9])([a-zA-Z])', point_maker, name.lower())
! 
          if label == TRUE:
              for r in config.IMDB_REMOVE_FROM_LABEL:
                  name  = re.sub(r, '', name)
!                 
          parts = re.split('[\._ -]', name)
          name = ''
          for p in parts:
!             if not p.lower() in config.IMDB_REMOVE_FROM_SEARCHSTRING and \
!                    not re.search(p, '[A-Za-z]'):
                  name += '%s ' % p
          return self.searchImdb(name)
  




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to