Add ebook support.
authorFabien Ninoles <fabien@tzone.org>
Sun, 11 Nov 2012 14:31:34 -0500
changeset 5 b6a3b0987bfc
parent 4 e102d2bb7a9e
child 6 0c6d2ed2cd7c
Add ebook support.
update-hib.py
--- a/update-hib.py	Sat Sep 22 13:45:10 2012 -0400
+++ b/update-hib.py	Sun Nov 11 14:31:34 2012 -0500
@@ -126,7 +126,8 @@
               ".deb"          : ("deb",),
               ".rpm"          : ("rpm",),
               "32-bit"        : ("x86",),
-              "64-bit"        : ("x64",),              
+              "64-bit"        : ("x64",),
+              "(HD)"          : ("HD",),
               }
     def __init__(self, dltype, dom):
         self.dltype = dltype
@@ -151,7 +152,7 @@
             self.size = "Unknown"
             self.md5 = "Unknown"
     def format(self, prefix=""):
-        res = prefix + '<download id="' + self.id + '">\n'
+        res = prefix + '<download type="' + self.dltype + '" id="' + self.id + '">\n'
         res += prefix + "  <web>" + self.web + "</web>\n"
         res += prefix + "  <torrent>" + self.torrent + "</torrent>\n"
         res += prefix + "  <size>" + self.size + "</size>\n"
@@ -260,6 +261,12 @@
             return score
         if dl.dltype == "android":
             return -1
+        if dl.dltype == "ebook":
+            if "MOBI" in dl.attrs:
+                return -1
+            if "HD" in dl.attrs:
+                return 2
+            return 1
         raise Exception("Unknown dls type: %r" % (dl,))
 
     def chooseDownloads(self, dls):