def _tryGetBookInfo(self, isbn, library): url = self._searchprefix + isbn + self._searchsuffix try: rssobj = urllib.urlopen(url) except IOError: print('Error: Could not read url ' + url) return False try: rssdoc = parse(rssobj) except xml.dom.DOMException: print('Error: Could not read RSS') return False finally: rssobj.close() nodes = rssdoc.getElementsByTagName(el_item) if(nodes.length < 0): return False for i in nodes: link = getTextNodeValue(i, el_link) try: data = harvestBookInfo(link, library) except Exception as e: print('BlogPostItem ' + self._rawtitle + ':\n ' + e.value) else: self._selectShelf(data.shelves) self.section = data.section return True return False
dims -- tuple containing normal width and height of the image smalldims -- tuple containing small width and height of the image library -- if not None only books from this library will be considered xmlnode -- if not None the OpacBookItem will be loaded from this cache node url -- if not None the OpacBookItem will be loaded from this url """ BookItem.__init__(self, dims, smalldims) if(xmlnode is not None): self._loadfromcache(xmlnode, dir) self.author = xmlnode.attributes[attr_author].value self._loadimage(dims, smalldims) elif(url is not None): try: data = itemharvester.harvestBookInfo(url, library) except: self.valid = False return self._rawtitle = data.title self.author = data.author self._rawtext = data.rawtext self.uid = data.isbn self._selectShelf(data.shelves) self.section = data.section self.subjects = data.subjects if(self.uid == ''): self.valid = False return
dims -- tuple containing normal width and height of the image smalldims -- tuple containing small width and height of the image library -- if not None only books from this library will be considered xmlnode -- if not None the OpacBookItem will be loaded from this cache node url -- if not None the OpacBookItem will be loaded from this url """ BookItem.__init__(self, dims, smalldims) if (xmlnode is not None): self._loadfromcache(xmlnode, dir) self.author = xmlnode.attributes[attr_author].value self._loadimage(dims, smalldims) elif (url is not None): try: data = itemharvester.harvestBookInfo(url, library) except: self.valid = False return self._rawtitle = data.title self.author = data.author self._rawtext = data.rawtext self.uid = data.isbn self._selectShelf(data.shelves) self.section = data.section self.subjects = data.subjects if (self.uid == ''): self.valid = False return