Skip to content

Commit

Permalink
Fix for websites with missing titles
Browse files Browse the repository at this point in the history
  • Loading branch information
wcember committed Jun 6, 2016
1 parent 73d7b2a commit 9617f45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pypub/chapter.py
Expand Up @@ -290,8 +290,11 @@ def create_chapter_from_string(self, html_string, url=None, title=None):
try:
root = BeautifulSoup(html_string, 'html.parser')
title_node = root.title
title = unicode(title_node.string)
except IndexError:
if title_node is not None:
title = unicode(title_node.string)
else:
raise ValueError
except (IndexError, ValueError):
title = 'Ebook Chapter'
return Chapter(clean_xhtml_string, title, url)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name='pypub',
version='1.2',
version='1.3',
packages=['pypub',],
package_data={'pypub': ['epub_templates/*',]},
author = 'William Cember',
Expand Down

0 comments on commit 9617f45

Please sign in to comment.