mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When reading metadata from very large HTML files, do not search the entire file for the metadata, as this can be very slow
This commit is contained in:
parent
20e46a53c6
commit
7895652c76
@ -34,6 +34,7 @@ def get_metadata_(src, encoding=None):
|
|||||||
# Title
|
# Title
|
||||||
title = None
|
title = None
|
||||||
pat = re.compile(r'<!--.*?TITLE=(?P<q>[\'"])(.+?)(?P=q).*?-->', re.DOTALL)
|
pat = re.compile(r'<!--.*?TITLE=(?P<q>[\'"])(.+?)(?P=q).*?-->', re.DOTALL)
|
||||||
|
src = src[:150000] # Searching shouldn't take too long
|
||||||
match = pat.search(src)
|
match = pat.search(src)
|
||||||
if match:
|
if match:
|
||||||
title = match.group(2)
|
title = match.group(2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user