123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- from common.public import clean_title
- from .aliyun_log import AliyunLogger
- class VideoItem:
- """
- function: 当扫描进一条视频的时候,对该视频的基本信息进行处理,保证发送给 pipeline和 etl 的 video_dict 是正确的
- __init__: 初始化空json 对象,用来存储视频信息
- add_video_info: 把视频信息存储到 item 对象中
- check_item: 检查 item 对象中的各个元素以及处理
- """
- def __init__(self):
- self.item = {}
- def add_video_info(self, key, value):
- self.item[key] = value
- # 判断视频格式, 做兼容
- def check_item(self):
- # video_title
- if self.item.get("video_title"):
- self.item['video_title'] = clean_title(self.item['video_title'])
- else:
- self.item['video_title'] = "No title"
- # video_id
- # video_time, publish_time_str, publish_time_stamp, update_time_stamp
- # play_cnt, like_cnt, comment_cnt, share_cnt
- # width, height, video_width, video_height
- # user_name, user_id, out_user_name, out_user_id
- # profile_id, profile_mid
- # session
- # video_url
- # cover_url
- def return_item(self):
- self.check_item()
- return self.item
|