mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement #991 (Add .oebzip extension)
This commit is contained in:
parent
d8e02cc76b
commit
5d3393d075
@ -95,7 +95,7 @@ def filename_to_utf8(name):
|
|||||||
def extract(path, dir):
|
def extract(path, dir):
|
||||||
ext = os.path.splitext(path)[1][1:].lower()
|
ext = os.path.splitext(path)[1][1:].lower()
|
||||||
extractor = None
|
extractor = None
|
||||||
if ext in ['zip', 'cbz', 'epub']:
|
if ext in ['zip', 'cbz', 'epub', 'oebzip']:
|
||||||
from calibre.libunzip import extract as zipextract
|
from calibre.libunzip import extract as zipextract
|
||||||
extractor = zipextract
|
extractor = zipextract
|
||||||
elif ext in ['cbr', 'rar']:
|
elif ext in ['cbr', 'rar']:
|
||||||
|
@ -18,4 +18,4 @@ class UnknownFormatError(Exception):
|
|||||||
|
|
||||||
BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm', 'xhtm',
|
BOOK_EXTENSIONS = ['lrf', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm', 'xhtm',
|
||||||
'html', 'xhtml', 'epub', 'pdf', 'prc', 'mobi', 'azw',
|
'html', 'xhtml', 'epub', 'pdf', 'prc', 'mobi', 'azw',
|
||||||
'epub', 'fb2', 'djvu', 'lrx', 'cbr', 'cbz']
|
'epub', 'fb2', 'djvu', 'lrx', 'cbr', 'cbz', 'oebzip']
|
||||||
|
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
'''Convert any ebook file into a LRF file.'''
|
'''Convert any ebook file into a LRF file.'''
|
||||||
|
|
||||||
import sys, os, logging, shutil, tempfile, glob, re
|
import sys, os, logging, shutil, tempfile, re
|
||||||
|
|
||||||
from calibre.ebooks import UnknownFormatError
|
from calibre.ebooks import UnknownFormatError
|
||||||
from calibre.ebooks.lrf import option_parser as _option_parser
|
from calibre.ebooks.lrf import option_parser as _option_parser
|
||||||
@ -30,7 +30,7 @@ def find_htmlfile(dir):
|
|||||||
toc_pat = re.compile(r'toc', re.IGNORECASE)
|
toc_pat = re.compile(r'toc', re.IGNORECASE)
|
||||||
toc_files, files = [], []
|
toc_files, files = [], []
|
||||||
for f in map(lambda x:os.path.join(dir, x), os.listdir(dir)):
|
for f in map(lambda x:os.path.join(dir, x), os.listdir(dir)):
|
||||||
name, ext = os.path.splitext(f)
|
ext = os.path.splitext(f)[1]
|
||||||
if ext and ext_pat.match(ext):
|
if ext and ext_pat.match(ext):
|
||||||
toc_files.append(f) if toc_pat.search(f) else files.append(f)
|
toc_files.append(f) if toc_pat.search(f) else files.append(f)
|
||||||
a = toc_files if toc_files else files
|
a = toc_files if toc_files else files
|
||||||
@ -74,7 +74,7 @@ def handle_archive(path):
|
|||||||
candidates = map(lambda x:os.path.join(cdir, x), os.listdir(cdir))
|
candidates = map(lambda x:os.path.join(cdir, x), os.listdir(cdir))
|
||||||
for ext in exts:
|
for ext in exts:
|
||||||
for f in candidates:
|
for f in candidates:
|
||||||
if f.lower().endswith(ext):
|
if f.lower().endswith('.'+ext):
|
||||||
files.append(f)
|
files.append(f)
|
||||||
file = largest_file(files)
|
file = largest_file(files)
|
||||||
if not file:
|
if not file:
|
||||||
@ -103,7 +103,7 @@ def process_file(path, options, logger=None):
|
|||||||
fmt = '.lrs' if options.lrs else '.lrf'
|
fmt = '.lrs' if options.lrs else '.lrf'
|
||||||
options.output = os.path.splitext(os.path.basename(path))[0] + fmt
|
options.output = os.path.splitext(os.path.basename(path))[0] + fmt
|
||||||
options.output = os.path.abspath(os.path.expanduser(options.output))
|
options.output = os.path.abspath(os.path.expanduser(options.output))
|
||||||
if ext in ['zip', 'rar']:
|
if ext in ['zip', 'rar', 'oebzip']:
|
||||||
newpath = None
|
newpath = None
|
||||||
try:
|
try:
|
||||||
tdir, newpath = handle_archive(path)
|
tdir, newpath = handle_archive(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user