Loading book_tools/format/bookfile.py +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ class BookFile(object): self.series_info = None self.language_code = None self.issues = [] self.docdate = '' def __enter__(self): return self Loading Loading @@ -47,6 +48,12 @@ class BookFile(object): if title: self.title = title def __set_docdate__(self, docdate): if docdate and BookFile.__is_text(docdate): docdate = docdate.strip() if docdate: self.docdate = docdate def __add_author__(self, name, sortkey=None): if not name or not BookFile.__is_text(name): return Loading book_tools/format/epub.py +6 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,12 @@ class EPub(BookFile): if len(res) > 0: self.__set_title__(res[0].text) res = tree.xpath('/opf:package/opf:metadata/dc:date[@event="modification"]', namespaces=namespaces) if len(res) == 0: res = tree.xpath('/opf:package/opf:metadata/dc:date', namespaces=namespaces) if len(res) > 0: self.__set_docdate__(res[0].text) res = tree.xpath('/opf:package/opf:metadata/dc:creator[@role="aut"]', namespaces=namespaces) if len(res) == 0: res = tree.xpath('/opf:package/opf:metadata/dc:creator', namespaces=namespaces) Loading book_tools/format/fb2.py +17 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ class FB2Base(BookFile): self.__detect_tags(tree) self.__detect_series_info(tree) self.__detect_language(tree) self.__detect_docdate(tree) description = self.__detect_description(tree) if description: self.description = description.strip() Loading Loading @@ -73,6 +74,22 @@ class FB2Base(BookFile): return None def __detect_docdate(self, tree): is_attrib = 1 res = tree.xpath('/fb:FictionBook/fb:description/fb:document-info/fb:date/@value', namespaces=self.__namespaces) if len(res) == 0: res = tree.xpath('/FictionBook/description/document-info/date/@value') if len(res) == 0: is_attrib = 0 res = tree.xpath('/fb:FictionBook/fb:description/fb:document-info/fb:date', namespaces=self.__namespaces) if len(res) == 0: is_attrib = 0 res = tree.xpath('/FictionBook/description/document-info/date') if len(res) > 0: self.__set_docdate__(res[0] if is_attrib else res[0].text) return None def __detect_authors(self, tree): use_namespaces = True Loading book_tools/format/mobi.py +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Mobipocket(BookFile): self._encryption_method = bm['encryption'] self.__set_title__(bm['title']) self.__add_author__(bm['author']) self.__set_docdate__(bm['modificationDate'].strftime("%Y-%m-%d")) if bm['subject']: for tag in bm['subject']: self.__add_tag__(tag) Loading opds_catalog/sopdscan.py +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ class opdsScanner: title = book_data.title.strip(self.strip_symbols) if book_data.title else n annotation = book_data.description if book_data.description else '' annotation = annotation.strip(self.strip_symbols) if isinstance(annotation, str) else annotation.decode('utf8').strip(self.strip_symbols) docdate = '' docdate = book_data.docdate if book_data.docdate else '' book=opdsdb.addbook(name,rel_path,cat,e[1:],title,annotation,docdate,lang,file_size,archive) self.books_added+=1 Loading Loading
book_tools/format/bookfile.py +7 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ class BookFile(object): self.series_info = None self.language_code = None self.issues = [] self.docdate = '' def __enter__(self): return self Loading Loading @@ -47,6 +48,12 @@ class BookFile(object): if title: self.title = title def __set_docdate__(self, docdate): if docdate and BookFile.__is_text(docdate): docdate = docdate.strip() if docdate: self.docdate = docdate def __add_author__(self, name, sortkey=None): if not name or not BookFile.__is_text(name): return Loading
book_tools/format/epub.py +6 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,12 @@ class EPub(BookFile): if len(res) > 0: self.__set_title__(res[0].text) res = tree.xpath('/opf:package/opf:metadata/dc:date[@event="modification"]', namespaces=namespaces) if len(res) == 0: res = tree.xpath('/opf:package/opf:metadata/dc:date', namespaces=namespaces) if len(res) > 0: self.__set_docdate__(res[0].text) res = tree.xpath('/opf:package/opf:metadata/dc:creator[@role="aut"]', namespaces=namespaces) if len(res) == 0: res = tree.xpath('/opf:package/opf:metadata/dc:creator', namespaces=namespaces) Loading
book_tools/format/fb2.py +17 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ class FB2Base(BookFile): self.__detect_tags(tree) self.__detect_series_info(tree) self.__detect_language(tree) self.__detect_docdate(tree) description = self.__detect_description(tree) if description: self.description = description.strip() Loading Loading @@ -73,6 +74,22 @@ class FB2Base(BookFile): return None def __detect_docdate(self, tree): is_attrib = 1 res = tree.xpath('/fb:FictionBook/fb:description/fb:document-info/fb:date/@value', namespaces=self.__namespaces) if len(res) == 0: res = tree.xpath('/FictionBook/description/document-info/date/@value') if len(res) == 0: is_attrib = 0 res = tree.xpath('/fb:FictionBook/fb:description/fb:document-info/fb:date', namespaces=self.__namespaces) if len(res) == 0: is_attrib = 0 res = tree.xpath('/FictionBook/description/document-info/date') if len(res) > 0: self.__set_docdate__(res[0] if is_attrib else res[0].text) return None def __detect_authors(self, tree): use_namespaces = True Loading
book_tools/format/mobi.py +1 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Mobipocket(BookFile): self._encryption_method = bm['encryption'] self.__set_title__(bm['title']) self.__add_author__(bm['author']) self.__set_docdate__(bm['modificationDate'].strftime("%Y-%m-%d")) if bm['subject']: for tag in bm['subject']: self.__add_tag__(tag) Loading
opds_catalog/sopdscan.py +1 −1 Original line number Diff line number Diff line Loading @@ -217,7 +217,7 @@ class opdsScanner: title = book_data.title.strip(self.strip_symbols) if book_data.title else n annotation = book_data.description if book_data.description else '' annotation = annotation.strip(self.strip_symbols) if isinstance(annotation, str) else annotation.decode('utf8').strip(self.strip_symbols) docdate = '' docdate = book_data.docdate if book_data.docdate else '' book=opdsdb.addbook(name,rel_path,cat,e[1:],title,annotation,docdate,lang,file_size,archive) self.books_added+=1 Loading