Skip to content

Commit

Permalink
v2.6.19 (#433)
Browse files Browse the repository at this point in the history
* fix(cache): 修正缓存精简逻辑

* refactor(routes): 去除多余的检查更新覆写逻辑

* chore(release): v2.6.19
  • Loading branch information
NekoAria authored May 8, 2023
1 parent 1369bcf commit fb32d0b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 66 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ELF_RSS"
version = "2.6.18"
version = "2.6.19"
description = "QQ机器人 RSS订阅 插件,订阅源建议选择 RSSHub"
authors = ["Quan666 <i@Rori.eMail>"]
license = "GPL-3.0-only"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ELF_RSS2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require("nonebot_plugin_apscheduler")
from nonebot_plugin_apscheduler import scheduler # noqa

VERSION = "2.6.18"
VERSION = "2.6.19"

__plugin_meta__ = PluginMetadata(
name="ELF_RSS",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ELF_RSS2/parsing/cache_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def cache_filter(data: Dict[str, Any]) -> Dict[str, Any]:
"summary",
"to_send",
]
return {k: data[k] for k in keys if k in data}
return {k: v for k in keys if (v := data.get(k))}


# 对去重数据库进行管理
Expand Down
33 changes: 0 additions & 33 deletions src/plugins/ELF_RSS2/parsing/routes/nga.py

This file was deleted.

29 changes: 1 addition & 28 deletions src/plugins/ELF_RSS2/parsing/routes/pixiv.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import re
import sqlite3
from typing import Any, Dict, List
from typing import Any, Dict

import aiohttp
from nonebot.log import logger
from pyquery import PyQuery as Pq
from tenacity import RetryError, TryAgain, retry, stop_after_attempt, stop_after_delay
from tinydb import Query, TinyDB

from ...config import DATA_PATH
from ...rss_class import Rss
from .. import ParsingBase, cache_db_manage, duplicate_exists, write_item
from ..check_update import get_item_date
from ..handle_images import (
get_preview_gif_from_video,
handle_img_combo,
Expand Down Expand Up @@ -145,28 +143,3 @@ async def handle_source(item: Dict[str, Any]) -> str:
# 缩短 pixiv 链接
str_link = re.sub("https://www.pixiv.net/artworks/", "https://pixiv.net/i/", source)
return f"链接:{str_link}\n"


# 检查更新
@ParsingBase.append_before_handler(rex="/pixiv/ranking/") # type: ignore
async def handle_check_update(state: Dict[str, Any]) -> Dict[str, Any]:
db = state["tinydb"]
change_data = check_update(db, state["new_data"])
return {"change_data": change_data}


# 检查更新
def check_update(db: TinyDB, new: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
# 发送失败 1 次
to_send_list: List[Dict[str, Any]] = db.search(Query().to_send.exists())

if not new and not to_send_list:
return []

old_link_list = [i["link"] for i in db.all()]
to_send_list.extend([i for i in new if i["link"] not in old_link_list])

# 对结果按照发布时间排序
to_send_list.sort(key=get_item_date)

return to_send_list
5 changes: 3 additions & 2 deletions src/plugins/ELF_RSS2/rss_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ async def filter_and_validate_rss(rss: Rss, bot: Bot) -> Rss:

async def save_first_time_fetch(rss: Rss, new_rss: Dict[str, Any]) -> None:
_file = DATA_PATH / f"{Rss.handle_name(rss.name)}.json"
entries = new_rss["entries"]
result = [cache_filter({**entry, "hash": dict_hash(entry)}) for entry in entries]
result = [cache_filter(entry) for entry in new_rss["entries"]]
for r in result:
r["hash"] = dict_hash(r)

with TinyDB(
_file,
Expand Down

0 comments on commit fb32d0b

Please sign in to comment.