From f6a5238b6ed3cb46b8ee39c0a0fe83be81b532aa Mon Sep 17 00:00:00 2001 From: amtoaer Date: Sun, 25 Feb 2024 00:47:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- processor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/processor.py b/processor.py index c89ee8b..d207679 100644 --- a/processor.py +++ b/processor.py @@ -173,12 +173,17 @@ async def process_favorite_item( if len(pages) == 1: single_page = True else: - pages = await FavoriteItemPage.bulk_create( + # 如果有多个分 p,那么先创建记录 + await FavoriteItemPage.bulk_create( pages, on_conflict=["favorite_item_id", "page"], update_fields=["cid", "name", "image"], batch_size=300, ) + # 重新拉一下数据,不能用 bulk create 的返回值,因为 bulk_create 不会填充主键 + pages = await FavoriteItemPage.filter(favorite_item=fav_item).order_by("page") + for page in pages: + page.favorite_item = fav_item if process_nfo: try: await get_nfo(fav_item.tvshow_nfo_path, obj=fav_item, mode=NfoMode.TVSHOW)