Loading book_tools/format/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ def create_bookfile(file, original_filename): if isinstance(file, str): file = open(file, 'rb') mimetype = detect_mime(file) file.seek(0,0) if mimetype == Mimetype.EPUB: return EPub(file, original_filename) elif mimetype == Mimetype.FB2: Loading book_tools/format/epub.py +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class EPub(BookFile): self.__initialize() def __initialize(self): self.file.seek(0,0) self.__zip_file = zipfile.ZipFile(self.file) self.issues = [] try: Loading book_tools/format/mobi.py +10 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,13 @@ class Mobipocket(BookFile): return (None, False) finally: shutil.rmtree(tmp_dir) def extract_cover_memory(self): try: image = BookMobi(self.file).unpackMobiCover() except Exception as err: print(err) image = None return image book_tools/pymobi/mobi.py +9 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,7 @@ class BookMobi(object): f = file self.filename = f.name self.f = f self.f.seek(0,0) # palm database header header = f.read(78) for key, u_fmt, offset in self.palmdb_format: Loading Loading @@ -556,6 +557,14 @@ class BookMobi(object): self.saveRecordImage(cover_rn, '%s_cover' % basename) print('Unpack MOBI successfully') def unpackMobiCover(self): if 201 in self.mobi_exth: cover_rn, = struct.unpack('>L', self.mobi_exth[201]) cover_rn += self.mobi['firstImageIndex'] rec = self.loadRecord(cover_rn) return rec return None def removeSrcs(self, outmobi, outsrcs=None): srcs_rn = self.mobi['srcsRecordNumber'] srcs_rc = self.mobi['srcsRecordCount'] Loading opds_catalog/dl.py +2 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ def Download(request, book_id, zip_flag): return response # Новая версия (0.42) процедуры извлечения обложек из файлов книг fb2, epub, mobi def Cover(request, book_id, thumbnail=False): """ Загрузка обложки """ book = Book.objects.get(id=book_id) Loading Loading @@ -153,6 +153,7 @@ def Cover(request, book_id, thumbnail=False): return response # Старая версия (до 0.41) процедуры извлечения обложек из файлов книг только fb2 def Cover0(request, book_id, thumbnail = False): """ Загрузка обложки """ book = Book.objects.get(id=book_id) Loading Loading
book_tools/format/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ def create_bookfile(file, original_filename): if isinstance(file, str): file = open(file, 'rb') mimetype = detect_mime(file) file.seek(0,0) if mimetype == Mimetype.EPUB: return EPub(file, original_filename) elif mimetype == Mimetype.FB2: Loading
book_tools/format/epub.py +1 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ class EPub(BookFile): self.__initialize() def __initialize(self): self.file.seek(0,0) self.__zip_file = zipfile.ZipFile(self.file) self.issues = [] try: Loading
book_tools/format/mobi.py +10 −0 Original line number Diff line number Diff line Loading @@ -35,3 +35,13 @@ class Mobipocket(BookFile): return (None, False) finally: shutil.rmtree(tmp_dir) def extract_cover_memory(self): try: image = BookMobi(self.file).unpackMobiCover() except Exception as err: print(err) image = None return image
book_tools/pymobi/mobi.py +9 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,7 @@ class BookMobi(object): f = file self.filename = f.name self.f = f self.f.seek(0,0) # palm database header header = f.read(78) for key, u_fmt, offset in self.palmdb_format: Loading Loading @@ -556,6 +557,14 @@ class BookMobi(object): self.saveRecordImage(cover_rn, '%s_cover' % basename) print('Unpack MOBI successfully') def unpackMobiCover(self): if 201 in self.mobi_exth: cover_rn, = struct.unpack('>L', self.mobi_exth[201]) cover_rn += self.mobi['firstImageIndex'] rec = self.loadRecord(cover_rn) return rec return None def removeSrcs(self, outmobi, outsrcs=None): srcs_rn = self.mobi['srcsRecordNumber'] srcs_rc = self.mobi['srcsRecordCount'] Loading
opds_catalog/dl.py +2 −1 Original line number Diff line number Diff line Loading @@ -97,7 +97,7 @@ def Download(request, book_id, zip_flag): return response # Новая версия (0.42) процедуры извлечения обложек из файлов книг fb2, epub, mobi def Cover(request, book_id, thumbnail=False): """ Загрузка обложки """ book = Book.objects.get(id=book_id) Loading Loading @@ -153,6 +153,7 @@ def Cover(request, book_id, thumbnail=False): return response # Старая версия (до 0.41) процедуры извлечения обложек из файлов книг только fb2 def Cover0(request, book_id, thumbnail = False): """ Загрузка обложки """ book = Book.objects.get(id=book_id) Loading