diff --git a/src/backend/lib/library.py b/src/backend/lib/library.py index 5cce59e..14c4f79 100755 --- a/src/backend/lib/library.py +++ b/src/backend/lib/library.py @@ -115,26 +115,37 @@ class Catalogue: except IndexError: # cover = self.extract_cover_html(book_zip, book) cover = DuckDuckGo().image_result(title) - try: description = self.stripTags(soup.find("dc:description").text) - except AttributeError: description = None - try: identifier = self.stripTags(soup.find("dc:identifier").text) - except AttributeError: identifier = None - try: publisher = self.stripTags(soup.find("dc:publisher").text) - except AttributeError: publisher = None - try: date = self.stripTags(soup.find("dc:date").text) - except AttributeError: date = None - try: rights = self.stripTags(soup.find("dc:rights").text) - except AttributeError: rights = None - try: tags = self.stripTags(soup.find_all("dc:subject").text) - except AttributeError: tags = None + try: + description = self.stripTags(soup.find("dc:description").text) + except AttributeError: + description = None + try: + identifier = self.stripTags(soup.find("dc:identifier").text) + except AttributeError: + identifier = None + try: + publisher = self.stripTags(soup.find("dc:publisher").text) + except AttributeError: + publisher = None + try: + date = self.stripTags(soup.find("dc:date").text) + except AttributeError: + date = None + try: + rights = self.stripTags(soup.find("dc:rights").text) + except AttributeError: + rights = None + try: + tags = soup.find_all("dc:subject") + except AttributeError: + tags = None ftags = None - breakpoint() if tags is not None: for tag in tags: if ftags is None: - ftags = tag + ftags = tag.text else: - ftags = ftags+","+tag + ftags = ftags + "," + tag.text book_details = [ title, author, @@ -145,14 +156,14 @@ class Catalogue: publisher, date, rights, - ftags + ftags, ] return book_details @staticmethod def stripTags(source): - p = re.compile(r'<.*?>') - return p.sub('', source) + p = re.compile(r"<.*?>") + return p.sub("", source) @staticmethod def extract_metadata_mobi(book): diff --git a/src/backend/lib/storage.py b/src/backend/lib/storage.py index 953d8ec..f066dbe 100755 --- a/src/backend/lib/storage.py +++ b/src/backend/lib/storage.py @@ -53,7 +53,7 @@ class Storage: Insert book in database :returns: True if succeeds False if not """ - q = "INSERT INTO books (title, author, cover, progress, file_name, pages) values (%s, %s, %s, 0, %s, 0);" + q = "INSERT INTO books (title, author, cover, progress, file_name, pages, description, publisher, date, rights, tags) values (%s, %s, %s, 0, %s, 0, %s, %s, %s, %s, %s);" try: try: cover_image = book[2].data @@ -61,7 +61,21 @@ class Storage: cover_image = book[2] if not book[2]: # If cover image is missing unset entry cover_image = None - self.cursor.execute(q, (book[0], book[1], cover_image, book[3])) + self.cursor.execute( + q, + ( + book[0], + book[1], + cover_image, + book[3], + book[4], + book[5], + book[6], + book[7], + book[8], + book[9], + ), + ) return True except Exception as e: print(e)