Xiaohongshu MongoDB storage implementation
| 249 | |
| 250 | |
| 251 | class XhsMongoStoreImplement(AbstractStore): |
| 252 | """Xiaohongshu MongoDB storage implementation""" |
| 253 | |
| 254 | def __init__(self, **kwargs): |
| 255 | super().__init__(**kwargs) |
| 256 | self.mongo_store = MongoDBStoreBase(collection_prefix="xhs") |
| 257 | |
| 258 | async def store_content(self, content_item: Dict): |
| 259 | """ |
| 260 | Store note content to MongoDB |
| 261 | Args: |
| 262 | content_item: Note content data |
| 263 | """ |
| 264 | note_id = content_item.get("note_id") |
| 265 | if not note_id: |
| 266 | return |
| 267 | |
| 268 | await self.mongo_store.save_or_update( |
| 269 | collection_suffix="contents", |
| 270 | query={"note_id": note_id}, |
| 271 | data=content_item |
| 272 | ) |
| 273 | utils.logger.info(f"[XhsMongoStoreImplement.store_content] Saved note {note_id} to MongoDB") |
| 274 | |
| 275 | async def store_comment(self, comment_item: Dict): |
| 276 | """ |
| 277 | Store comment to MongoDB |
| 278 | Args: |
| 279 | comment_item: Comment data |
| 280 | """ |
| 281 | comment_id = comment_item.get("comment_id") |
| 282 | if not comment_id: |
| 283 | return |
| 284 | |
| 285 | await self.mongo_store.save_or_update( |
| 286 | collection_suffix="comments", |
| 287 | query={"comment_id": comment_id}, |
| 288 | data=comment_item |
| 289 | ) |
| 290 | utils.logger.info(f"[XhsMongoStoreImplement.store_comment] Saved comment {comment_id} to MongoDB") |
| 291 | |
| 292 | async def store_creator(self, creator_item: Dict): |
| 293 | """ |
| 294 | Store creator information to MongoDB |
| 295 | Args: |
| 296 | creator_item: Creator data |
| 297 | """ |
| 298 | # 教学版:创作者个人资料不再落库 |
| 299 | pass |
| 300 | |
| 301 | |
| 302 | class XhsExcelStoreImplement: |