This commit is contained in:
Kovid Goyal 2008-03-27 06:07:18 +00:00
parent 7b6f402cbc
commit b1ede44bee

View File

@ -16,10 +16,10 @@ def get_metadata(stream):
# Title
title = None
pat = re.compile(r'<!--.*?TITLE=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
pat = re.compile(r'<!--.*?TITLE=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
match = pat.search(src)
if match:
title = match.group(1)
title = match.group(2)
else:
pat = re.compile('<title>([^<>]+?)</title>', re.IGNORECASE)
match = pat.search(src)
@ -28,18 +28,18 @@ def get_metadata(stream):
# Author
author = None
pat = re.compile(r'<!--.*?AUTHOR=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
pat = re.compile(r'<!--.*?AUTHOR=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
match = pat.search(src)
if match:
author = match.group(1).replace(',', ';')
author = match.group(2).replace(',', ';')
mi = MetaInformation(title, [author] if author else None)
# Publisher
pat = re.compile(r'<!--.*?PUBLISHER=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)
pat = re.compile(r'<!--.*?PUBLISHER=(?P<q>[\'"])(.+)(?P=q).*?-->', re.DOTALL)
match = pat.search(src)
if match:
mi.publisher = match.group(1)
mi.publisher = match.group(2)
# ISBN
pat = re.compile(r'<!--.*?ISBN=[\'"]([^"\']+)[\'"].*?-->', re.DOTALL)