Fallback to default pattern if even version0 fails to compile

This commit is contained in:
Kovid Goyal 2020-10-07 20:11:19 +05:30
parent 9e0f63cb2f
commit 8757d4e775
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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: