update-hib.py
changeset 12 9d5880ecdb82
parent 11 dc1b075c538a
child 13 7567c5e4db45
equal deleted inserted replaced
11:dc1b075c538a 12:9d5880ecdb82
   132         for child in soup.children:
   132         for child in soup.children:
   133             if type(child) is not bs4.element.Tag:
   133             if type(child) is not bs4.element.Tag:
   134                 continue
   134                 continue
   135             classes = child["class"] if "class" in child.attrs else []
   135             classes = child["class"] if "class" in child.attrs else []
   136             if "gameinfo" in classes:
   136             if "gameinfo" in classes:
   137                 self.title = child.find(class_="title").a.string.strip()
   137                 divTitle = child.find(class_="title")
       
   138                 if divTitle.a:
       
   139                     divTitle = divTitle.a
       
   140                 self.title = divTitle.string.strip()
   138             elif "downloads" in classes:
   141             elif "downloads" in classes:
   139                 logging.debug("Collecting downloadables for %s", self.title)
   142                 logging.debug("Collecting downloadables for %s", self.title)
   140                 self.downloads.append(Downloads(child))
   143                 self.downloads.append(Downloads(child))
   141             elif [True for attr in classes if attr in ["icn", "clearfix"]]:
   144             elif [True for attr in classes if attr in ["icn", "clearfix"]]:
   142                 pass
   145                 pass
   196         if dl.dltype == "android":
   199         if dl.dltype == "android":
   197             return -1
   200             return -1
   198         if dl.dltype == "ebook":
   201         if dl.dltype == "ebook":
   199             if "MOBI" in dl.attrs:
   202             if "MOBI" in dl.attrs:
   200                 return -1
   203                 return -1
   201             if "HD" in dl.attrs:
       
   202                 return 2
       
   203             return 1
   204             return 1
   204         raise Exception("Unknown dls type: %r" % (dl,))
   205         raise Exception("Unknown dls type: %r" % (dl,))
   205 
   206 
   206     def chooseDownloads(self, dls):
   207     def chooseDownloads(self, dls):
   207         return sorted(((self.scoreDownload(dl),dl) for dl in dls), key=lambda x: x[0], reverse=True)
   208         return sorted(((self.scoreDownload(dl),dl) for dl in dls), key=lambda x: x[0], reverse=True)