mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-06-06 09:57:25 +08:00
fix(数据库): 修复模型字段类型以支持更广泛的数据格式;
修复xhs评论存储方法,从批量处理改为单条处理
This commit is contained in:
@@ -143,18 +143,17 @@ class XhsDbStoreImplement(AbstractStore):
|
||||
result = await session.execute(stmt)
|
||||
return result.first() is not None
|
||||
|
||||
async def store_comments(self, comments: List[Dict]):
|
||||
if not comments:
|
||||
async def store_comment(self, comment_item: Dict):
|
||||
if not comment_item:
|
||||
return
|
||||
async with get_session() as session:
|
||||
for comment_item in comments:
|
||||
comment_id = comment_item.get("comment_id")
|
||||
if not comment_id:
|
||||
continue
|
||||
if await self.comment_is_exist(session, comment_id):
|
||||
await self.update_comment(session, comment_item)
|
||||
else:
|
||||
await self.add_comment(session, comment_item)
|
||||
comment_id = comment_item.get("comment_id")
|
||||
if not comment_id:
|
||||
return
|
||||
if await self.comment_is_exist(session, comment_id):
|
||||
await self.update_comment(session, comment_item)
|
||||
else:
|
||||
await self.add_comment(session, comment_item)
|
||||
|
||||
async def add_comment(self, session: AsyncSession, comment_item: Dict):
|
||||
add_ts = int(get_current_timestamp())
|
||||
|
||||
Reference in New Issue
Block a user