mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #603
This commit is contained in:
parent
7b6f402cbc
commit
b1ede44bee
@ -16,10 +16,10 @@ def get_metadata(stream):
|
|||||||
|
|
||||||
# Title
|
# Title
|
||||||
title = None
|
title = None
|
||||||
pat = re.compile(r'<!--.*?TITLE=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
|
pat = re.compile(r'<!--.*?TITLE=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
|
||||||
match = pat.search(src)
|
match = pat.search(src)
|
||||||
if match:
|
if match:
|
||||||
title = match.group(1)
|
title = match.group(2)
|
||||||
else:
|
else:
|
||||||
pat = re.compile('<title>([^<>]+?)</title>', re.IGNORECASE)
|
pat = re.compile('<title>([^<>]+?)</title>', re.IGNORECASE)
|
||||||
match = pat.search(src)
|
match = pat.search(src)
|
||||||
@ -28,18 +28,18 @@ def get_metadata(stream):
|
|||||||
|
|
||||||
# Author
|
# Author
|
||||||
author = None
|
author = None
|
||||||
pat = re.compile(r'<!--.*?AUTHOR=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
|
pat = re.compile(r'<!--.*?AUTHOR=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
|
||||||
match = pat.search(src)
|
match = pat.search(src)
|
||||||
if match:
|
if match:
|
||||||
author = match.group(1).replace(',', ';')
|
author = match.group(2).replace(',', ';')
|
||||||
|
|
||||||
mi = MetaInformation(title, [author] if author else None)
|
mi = MetaInformation(title, [author] if author else None)
|
||||||
|
|
||||||
# Publisher
|
# Publisher
|
||||||
pat = re.compile(r'<!--.*?PUBLISHER=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
|
pat = re.compile(r'<!--.*?PUBLISHER=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
|
||||||
match = pat.search(src)
|
match = pat.search(src)
|
||||||
if match:
|
if match:
|
||||||
mi.publisher = match.group(1)
|
mi.publisher = match.group(2)
|
||||||
|
|
||||||
# ISBN
|
# ISBN
|
||||||
pat = re.compile(r'<!--.*?ISBN=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
|
pat = re.compile(r'<!--.*?ISBN=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user