|
@@ -12,6 +12,30 @@ from data_channel.data_help import dataHelp
|
|
|
|
|
|
class KS:
|
|
class KS:
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
+ def get_share_count(cls, v_id):
|
|
|
|
+ url = "http://8.217.190.241:8888/crawler/kuai_shou/detail"
|
|
|
|
+
|
|
|
|
+ payload = json.dumps({
|
|
|
|
+ "content_id": v_id
|
|
|
|
+ })
|
|
|
|
+ headers = {
|
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
+ response = response.json()
|
|
|
|
+ try:
|
|
|
|
+ if response["code"] == 0:
|
|
|
|
+ data = response["data"]["data"]
|
|
|
|
+ share_count = data.get("share_count")
|
|
|
|
+ return int(share_count)
|
|
|
|
+ else:
|
|
|
|
+ return 0
|
|
|
|
+ except KeyError as e:
|
|
|
|
+ Common.logger("ks").info(f"获取分享数据失败:{e}\n")
|
|
|
|
+ return 0
|
|
|
|
+
|
|
@classmethod
|
|
@classmethod
|
|
def get_ks_url(cls, task_mark, url_id, number, mark, feishu_id, cookie_sheet, channel_id, name):
|
|
def get_ks_url(cls, task_mark, url_id, number, mark, feishu_id, cookie_sheet, channel_id, name):
|
|
list = []
|
|
list = []
|
|
@@ -75,23 +99,26 @@ class KS:
|
|
video_id = feeds[i].get("photo", {}).get("id", "")
|
|
video_id = feeds[i].get("photo", {}).get("id", "")
|
|
status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
|
|
status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
|
|
if status:
|
|
if status:
|
|
|
|
+ share_count = cls.get_share_count(video_id)
|
|
old_title = feeds[i].get("photo", {}).get("caption")
|
|
old_title = feeds[i].get("photo", {}).get("caption")
|
|
cover_url = feeds[i].get('photo', {}).get('coverUrl', "")
|
|
cover_url = feeds[i].get('photo', {}).get('coverUrl', "")
|
|
video_url = feeds[i].get('photo', {}).get('photoUrl', "")
|
|
video_url = feeds[i].get('photo', {}).get('photoUrl', "")
|
|
- # viewCount = int(feeds[i].get('photo', {}).get('viewCount', 0))
|
|
|
|
|
|
+ view_count = int(feeds[i].get('photo', {}).get('viewCount', 0))
|
|
realLikeCount = int(feeds[i].get('photo', {}).get('realLikeCount', 0))
|
|
realLikeCount = int(feeds[i].get('photo', {}).get('realLikeCount', 0))
|
|
- if realLikeCount < 10000:
|
|
|
|
- Common.logger("ks").info(f"任务:{task_mark},用户主页id:{url_id},视频id{video_id} ,点赞数:{realLikeCount} ")
|
|
|
|
- continue
|
|
|
|
|
|
+ video_percent = '%.4f' % (share_count / view_count)
|
|
duration = dataHelp.video_duration(video_url)
|
|
duration = dataHelp.video_duration(video_url)
|
|
- if int(duration) >= 45:
|
|
|
|
- all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": realLikeCount, "old_title": old_title}
|
|
|
|
- list.append(all_data)
|
|
|
|
- if len(list) == int(number):
|
|
|
|
- Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")
|
|
|
|
- return list
|
|
|
|
- else:
|
|
|
|
- Common.logger("ks").info(f"任务:{task_mark},用户主页id:{url_id},视频id{video_id} ,点赞数:{realLikeCount} ,时长:{duration} ")
|
|
|
|
|
|
+ special = float(0.001)
|
|
|
|
+ if float(video_percent) < special or share_count < 500 or duration < 30 or duration > 600:
|
|
|
|
+ Common.logger("ks").info(
|
|
|
|
+ f"任务:{task_mark},用户主页id:{url_id},视频id{video_id} ,播放数:{view_count} ,分享数:{share_count},时长:{duration} ")
|
|
|
|
+ continue
|
|
|
|
+ all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
|
|
|
|
+ list.append(all_data)
|
|
|
|
+ if len(list) == int(number):
|
|
|
|
+ Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")
|
|
|
|
+ return list
|
|
|
|
|
|
return list
|
|
return list
|
|
|
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ KS.get_share_count("3x8ssbwg6bw9tqs")
|