예제 #1
0
 def retrieve(self,text):
     bi = BookInfo()
     bi.authors, bi.title = Retriever.get_authors_and_title(text)
     bi.pagelink = self.link
     bi.links['txt'] = self.link
     tag = Retriever.get_tag_by_link(self.link)
     bi.tags = [tag] if tag else []
     return bi
예제 #2
0
 def execute(self,html):
     soup = get_soup(html)
     book_info = BookInfo()
     book_info.title  = self.description['title']
     book_info.authors = [ "%s %s %s" % (self.description['firstname'],self.description['middlename'], self.description['lastname']) ]
     book_info.pagelink = self.link
     book_info.language = self.description['language']
     book_info.summary = Retriever.get_summary(soup)
     book_info.links = Retriever.get_links(soup, self.link)
     book_info.tags = Retriever.get_tags(soup)
     book_info.image = Retriever.get_picture(soup, self.link, self.description['ID'])
     self.tasks = [ BookSavingTask(book_info) ]
     return True
예제 #3
0
def get_bookinfo_from_db(id):
    bookinfo = BookInfo()
    book = Book.objects.get(id=id)
    bookinfo.title = book.title
    bookinfo.authors = [ author.name for author in book.author.all() ]
    bookinfo.pagelink = book.pagelink
    bookinfo.language = book.language.short
    annotations = book.annotation_set.all()
    if annotations:
        bookinfo.summary = annotations[0]
    for bookfile in book.book_file.all():
        bookinfo.links[bookfile.type] = bookfile.link
    bookinfo.tags = [ tag.name for tag in book.tag.all()]
    bookinfo.image = book.image.name if book.image else None
    return bookinfo