Skip to content

Commit

Permalink
v2.4.1 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
c3kay authored Dec 7, 2024
2 parents 330e35b + 51b46e1 commit 02edc7c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ classifiers = [
"Topic :: Internet :: WWW/HTTP :: Dynamic Content :: News/Diary"
]
dependencies = [
"aiohttp == 3.9.5",
"aiohttp == 3.11.10",
"aiofiles == 24.1.0",
"pydantic >= 1.10.0, < 2",
'tomli == 2.0.1 ; python_version < "3.11"'
'tomli == 2.2.1 ; python_version < "3.11"'
]
dynamic = ["version"]

Expand Down
4 changes: 3 additions & 1 deletion src/hoyolabrssfeeds/hoyolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ async def get_feed_item(
"title": post["post"]["subject"],
"author": post["user"]["nickname"],
"content": post["post"]["content"],
"summary": post["post"]["desc"],
"category": post["post"]["official_type"],
"published": post["post"]["created_at"],
}

if "desc" in post["post"] and len(post["post"]["desc"]) > 0:
item["summary"] = post["post"]["desc"]

if post["last_modify_time"] > 0:
item["updated"] = post["last_modify_time"]

Expand Down
4 changes: 3 additions & 1 deletion src/hoyolabrssfeeds/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ async def get_feed_items(self) -> List[FeedItem]:
"title": item["title"],
"author": item["authors"][0]["name"],
"content": item["content_html"],
"summary": item["summary"],
"category": category,
"published": item["date_published"],
}

if "summary" in item:
item_dict["summary"] = item["summary"]

if "date_modified" in item:
item_dict["updated"] = item["date_modified"]

Expand Down
2 changes: 1 addition & 1 deletion src/hoyolabrssfeeds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class FeedItem(MyBaseModel):
title: str
author: str
content: str
summary: str
category: FeedItemCategory
published: datetime
updated: Optional[datetime] = None
image: Optional[HttpUrl] = None
summary: Optional[str] = None


class FeedItemMeta(MyBaseModel):
Expand Down
7 changes: 5 additions & 2 deletions src/hoyolabrssfeeds/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ def create_json_feed_item(item: FeedItem) -> Dict[str, Any]:
"authors": [{"name": item.author}],
"tags": [item.category.name.title()],
"content_html": item.content,
"summary": item.summary,
"date_published": item.published.astimezone().isoformat(),
}

if item.summary is not None:
json_item["summary"] = item.summary

if item.updated is not None:
json_item["date_modified"] = item.updated.astimezone().isoformat()

Expand Down Expand Up @@ -212,7 +214,8 @@ def create_atom_feed_entries(
item.content
)

ElementTree.SubElement(entry, "summary").text = item.summary
if item.summary is not None:
ElementTree.SubElement(entry, "summary").text = item.summary

entries.append(entry)

Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,6 @@ def validate_hoyolab_post(post: Dict[str, Any], is_full_post: bool) -> None:
assert type(post["post"]["content"]) is str
assert len(post["post"]["content"]) > 0

assert type(post["post"]["desc"]) is str
assert len(post["post"]["desc"]) > 0

assert type(post["post"]["structured_content"]) is str
assert len(post["post"]["structured_content"]) > 0

Expand All @@ -329,3 +326,6 @@ def validate_hoyolab_post(post: Dict[str, Any], is_full_post: bool) -> None:

assert type(post["cover_list"]) is list
assert len(post["cover_list"]) >= 0

assert type(post["post"]["desc"]) is str
assert len(post["post"]["desc"]) >= 0

0 comments on commit 02edc7c

Please sign in to comment.