mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Comic Input: Replace the # character in filenames as it can cause problem with conversion/vieweing. Fixes #792723 (ebook viewer cannot open cbr with # in image name)
This commit is contained in:
parent
88e8e9db7e
commit
7f7d900fef
@ -11,7 +11,7 @@ import os, shutil, traceback, textwrap, time, codecs
|
|||||||
from Queue import Empty
|
from Queue import Empty
|
||||||
|
|
||||||
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
|
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
|
||||||
from calibre import extract, CurrentDir, prints
|
from calibre import extract, CurrentDir, prints, walk
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.utils.ipc.server import Server
|
from calibre.utils.ipc.server import Server
|
||||||
@ -27,6 +27,11 @@ def extract_comic(path_to_comic_file):
|
|||||||
# names
|
# names
|
||||||
tdir = tdir.decode(filesystem_encoding)
|
tdir = tdir.decode(filesystem_encoding)
|
||||||
extract(path_to_comic_file, tdir)
|
extract(path_to_comic_file, tdir)
|
||||||
|
for x in walk(tdir):
|
||||||
|
bn = os.path.basename(x)
|
||||||
|
nbn = bn.replace('#', '_')
|
||||||
|
if nbn != bn:
|
||||||
|
os.rename(x, os.path.join(os.path.dirname(x), nbn))
|
||||||
return tdir
|
return tdir
|
||||||
|
|
||||||
def find_pages(dir, sort_on_mtime=False, verbose=False):
|
def find_pages(dir, sort_on_mtime=False, verbose=False):
|
||||||
@ -362,6 +367,7 @@ class ComicInput(InputFormatPlugin):
|
|||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
fname, title = line.partition(':')[0], line.partition(':')[-1]
|
fname, title = line.partition(':')[0], line.partition(':')[-1]
|
||||||
|
fname = fname.replace('#', '_')
|
||||||
fname = os.path.join(tdir, *fname.split('/'))
|
fname = os.path.join(tdir, *fname.split('/'))
|
||||||
if not title:
|
if not title:
|
||||||
title = os.path.basename(fname).rpartition('.')[0]
|
title = os.path.basename(fname).rpartition('.')[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user