mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-10-10 05:30:56 +08:00
fix: 移除orm的所有内容
This commit is contained in:
@@ -6,7 +6,6 @@ from typing import List
|
||||
|
||||
import config
|
||||
|
||||
from .kuaishou_store_db_types import *
|
||||
from .kuaishou_store_impl import *
|
||||
|
||||
|
||||
@@ -48,7 +47,8 @@ async def update_kuaishou_video(video_item: Dict):
|
||||
"video_cover_url": photo_info.get("coverUrl", ""),
|
||||
"video_play_url": photo_info.get("photoUrl", ""),
|
||||
}
|
||||
utils.logger.info(f"[store.kuaishou.update_kuaishou_video] Kuaishou video id:{video_id}, title:{save_content_item.get('title')}")
|
||||
utils.logger.info(
|
||||
f"[store.kuaishou.update_kuaishou_video] Kuaishou video id:{video_id}, title:{save_content_item.get('title')}")
|
||||
await KuaishouStoreFactory.create_store().store_content(content_item=save_content_item)
|
||||
|
||||
|
||||
@@ -73,5 +73,6 @@ async def update_ks_video_comment(video_id: str, comment_item: Dict):
|
||||
"sub_comment_count": str(comment_item.get("subCommentCount", 0)),
|
||||
"last_modify_ts": utils.get_current_timestamp(),
|
||||
}
|
||||
utils.logger.info(f"[store.kuaishou.update_ks_video_comment] Kuaishou video comment: {comment_id}, content: {save_comment_item.get('content')}")
|
||||
await KuaishouStoreFactory.create_store().store_comment(comment_item=save_comment_item)
|
||||
utils.logger.info(
|
||||
f"[store.kuaishou.update_ks_video_comment] Kuaishou video comment: {comment_id}, content: {save_comment_item.get('content')}")
|
||||
await KuaishouStoreFactory.create_store().store_comment(comment_item=save_comment_item)
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author : relakkes@gmail.com
|
||||
# @Time : 2024/1/14 20:03
|
||||
# @Desc : 快手存储到DB的模型类集合
|
||||
|
||||
|
||||
from tortoise import fields
|
||||
from tortoise.models import Model
|
||||
|
||||
|
||||
class KuaishouBaseModel(Model):
|
||||
id = fields.IntField(pk=True, autoincrement=True, description="自增ID")
|
||||
user_id = fields.CharField(null=True, max_length=64, description="用户ID")
|
||||
nickname = fields.CharField(null=True, max_length=64, description="用户昵称")
|
||||
avatar = fields.CharField(null=True, max_length=255, description="用户头像地址")
|
||||
add_ts = fields.BigIntField(description="记录添加时间戳")
|
||||
last_modify_ts = fields.BigIntField(description="记录最后修改时间戳")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class KuaishouVideo(KuaishouBaseModel):
|
||||
video_id = fields.CharField(max_length=64, index=True, description="视频ID")
|
||||
video_type = fields.CharField(max_length=16, description="视频类型")
|
||||
title = fields.CharField(null=True, max_length=500, description="视频标题")
|
||||
desc = fields.TextField(null=True, description="视频描述")
|
||||
create_time = fields.BigIntField(description="视频发布时间戳", index=True)
|
||||
liked_count = fields.CharField(null=True, max_length=16, description="视频点赞数")
|
||||
viewd_count = fields.CharField(null=True, max_length=16, description="视频浏览数量")
|
||||
video_url = fields.CharField(null=True, max_length=512, description="视频详情URL")
|
||||
video_cover_url = fields.CharField(null=True, max_length=512, description="视频封面图 URL")
|
||||
video_play_url = fields.CharField(null=True, max_length=512, description="视频播放 URL")
|
||||
|
||||
class Meta:
|
||||
table = "kuaishou_video"
|
||||
table_description = "快手视频"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.video_id} - {self.title}"
|
||||
|
||||
|
||||
class KuaishouVideoComment(KuaishouBaseModel):
|
||||
comment_id = fields.CharField(max_length=64, index=True, description="评论ID")
|
||||
video_id = fields.CharField(max_length=64, index=True, description="视频ID")
|
||||
content = fields.TextField(null=True, description="评论内容")
|
||||
create_time = fields.BigIntField(description="评论时间戳")
|
||||
sub_comment_count = fields.CharField(max_length=16, description="评论回复数")
|
||||
|
||||
class Meta:
|
||||
table = "kuaishou_video_comment"
|
||||
table_description = "快手视频评论"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.comment_id} - {self.content}"
|
||||
@@ -10,7 +10,6 @@ import pathlib
|
||||
from typing import Dict
|
||||
|
||||
import aiofiles
|
||||
from tortoise.contrib.pydantic import pydantic_model_creator
|
||||
|
||||
from base.base_crawler import AbstractStore
|
||||
from tools import utils
|
||||
@@ -83,7 +82,6 @@ class KuaishouDbStoreImplement(AbstractStore):
|
||||
|
||||
"""
|
||||
|
||||
|
||||
from .kuaishou_store_sql import (add_new_content,
|
||||
query_content_by_content_id,
|
||||
update_content_by_content_id)
|
||||
@@ -116,7 +114,6 @@ class KuaishouDbStoreImplement(AbstractStore):
|
||||
await update_comment_by_comment_id(comment_id, comment_item=comment_item)
|
||||
|
||||
|
||||
|
||||
class KuaishouJsonStoreImplement(AbstractStore):
|
||||
json_store_path: str = "data/kuaishou"
|
||||
lock = asyncio.Lock()
|
||||
@@ -155,7 +152,6 @@ class KuaishouJsonStoreImplement(AbstractStore):
|
||||
async with aiofiles.open(save_file_name, 'w', encoding='utf-8') as file:
|
||||
await file.write(json.dumps(save_data, ensure_ascii=False))
|
||||
|
||||
|
||||
async def store_content(self, content_item: Dict):
|
||||
"""
|
||||
content JSON storage implementation
|
||||
|
||||
Reference in New Issue
Block a user