mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fallback to default pattern if even version0 fails to compile
This commit is contained in:
parent
9e0f63cb2f
commit
8757d4e775
@ -136,7 +136,11 @@ def metadata_from_filename(name, pat=None, fallback_pat=None):
|
||||
try:
|
||||
pat = regex.compile(prefs.get('filename_pattern'), flags=regex.UNICODE | regex.VERSION1 | regex.FULLCASE)
|
||||
except Exception:
|
||||
pat = regex.compile(prefs.get('filename_pattern'), flags=regex.UNICODE | regex.VERSION0 | regex.FULLCASE)
|
||||
try:
|
||||
pat = regex.compile(prefs.get('filename_pattern'), flags=regex.UNICODE | regex.VERSION0 | regex.FULLCASE)
|
||||
except Exception:
|
||||
pat = regex.compile('(?P<title>.+) - (?P<author>[^_]+)', flags=regex.UNICODE | regex.VERSION0 | regex.FULLCASE)
|
||||
|
||||
name = name.replace('_', ' ')
|
||||
match = pat.search(name)
|
||||
if match is None and fallback_pat is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user