Esempio n. 1
0
 def _getPersons(self, s, sep="<br/>"):
     """Return a list of Person objects, from the string s; items
     are assumed to be separated by the sep string."""
     names = s.split(sep)
     pl = []
     plappend = pl.append
     counter = 1
     for name in names:
         pid = re_imdbID.findall(name)
         if not pid:
             continue
         characters = _getTagsWith(name, 'class="char"', toClosure=True, maxRes=1)
         chpids = []
         if characters:
             for ch in characters[0].split(" / "):
                 chid = re_imdbID.findall(ch)
                 if not chid:
                     chpids.append(None)
                 else:
                     chpids.append(chid[-1])
         if not chpids:
             chpids = None
         elif len(chpids) == 1:
             chpids = chpids[0]
         name = _unHtml(name)
         # Catch unclosed tags.
         gt_indx = name.find(">")
         if gt_indx != -1:
             name = name[gt_indx + 1 :].lstrip()
         if not name:
             continue
         if name.endswith("..."):
             name = name[:-3]
         p = build_person(
             name,
             personID=str(pid[0]),
             billingPos=counter,
             modFunct=self._defModFunct,
             roleID=chpids,
             accessSystem=self.accessSystem,
         )
         plappend(p)
         counter += 1
     return pl
Esempio n. 2
0
 def _getPersons(self, s, sep='<br/>'):
     """Return a list of Person objects, from the string s; items
     are assumed to be separated by the sep string."""
     names = s.split(sep)
     pl = []
     plappend = pl.append
     counter = 1
     for name in names:
         pid = re_imdbID.findall(name)
         if not pid: continue
         characters = _getTagsWith(name, 'class="char"',
                                     toClosure=True, maxRes=1)
         chpids = []
         if characters:
             for ch in characters[0].split(' / '):
                 chid = re_imdbID.findall(ch)
                 if not chid:
                     chpids.append(None)
                 else:
                     chpids.append(chid[-1])
         if not chpids:
             chpids = None
         elif len(chpids) == 1:
             chpids = chpids[0]
         
         image = _findBetween(name, '<img src="', '"', maxRes=1)
         image_url = ''
         if image:
             image_url = image[0]
         
         name = _unHtml(name)
         # Catch unclosed tags.
         gt_indx = name.find('>')
         if gt_indx != -1:
             name = name[gt_indx+1:].lstrip()
         if not name: continue
         if name.endswith('...'):
             name = name[:-3]
         p = build_person(name, personID=str(pid[0]), billingPos=counter,
                         modFunct=self._defModFunct, roleID=chpids,
                         accessSystem=self.accessSystem, image=image_url)
         plappend(p)
         counter += 1
     return pl