Skip to content

Commit dbe5543

Browse files
Split integration tests to separate files and add test for salam pax's blog
1 parent 9054120 commit dbe5543

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

blog2epub/crawlers/article_factory/blogspot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
class BlogspotArticleFactory(DefaultArticleFactory):
1010
def get_title(self) -> Optional[str]:
1111
title = super().get_title()
12-
if self.blog_title is not None and title == self.blog_title:
13-
title = "Pomidor"
12+
date = self.get_date()
13+
if self.blog_title is not None and title == self.blog_title and date is not None:
14+
title = date.strftime("%A, %d %B %Y, %H:%M")
1415
return title
1516

1617
def process(self) -> ArticleModel:

blog2epub/crawlers/article_factory/default.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ def get_title(self) -> Optional[str]:
2222
if title_pattern.xpath:
2323
title = self.tree.xpath(title_pattern.xpath)
2424
if len(title) > 1:
25-
title = title[0]
26-
title = html.unescape(title.strip())
25+
title = html.unescape(title[0].strip())
2726
break
27+
while isinstance(title, list):
28+
try:
29+
title = title[0]
30+
except IndexError:
31+
title = None
2832
return title
2933

3034
def get_date(self) -> Optional[datetime]:

poetry.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ click = "^8.1.7"
3131
webencodings = "^0.5.1"
3232
soupsieve = "^2.6"
3333
pytz = "^2024.2"
34+
ftfy = "^6.3.1"
3435

3536
[tool.poetry.group.docs.dependencies]
3637
mkdocs = "^1.6.0"

0 commit comments

Comments
 (0)