resend_msg.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import json
  2. from common.mq import MQ
  3. from tqdm import tqdm
  4. if __name__ == "__main__":
  5. # path = 'message.txt'
  6. # with open(path, "r", encoding="utf-8") as f:
  7. # datas = f.readlines()
  8. # for line in tqdm(datas):
  9. # # for line in datas:
  10. # video_dict = {}
  11. # msg = json.loads(line)['msg']
  12. # # print(msg)
  13. # platform = json.loads(line)['platform']
  14. # strategy = json.loads(line)['strategy']
  15. # strs = msg.replace("CrawlerEtlParam", "")[1: -1]
  16. # str_list = strs.split(", ")
  17. # str_list = [i.replace("'", "") for i in str_list]
  18. # key_dict = {
  19. # "crawlerRule": "crawler_rule",
  20. # "userId": "user_id",
  21. # "outUserId": "out_user_id",
  22. # "userName": "user_name",
  23. # "avatarUrl": "avatar_url",
  24. # "outVideoId": "out_video_id",
  25. # "videoTitle": "video_title",
  26. # "coverUrl": "cover_url",
  27. # "videoUrl": "video_url",
  28. # "publishTime": "publish_time",
  29. # "playCnt": "play_cnt",
  30. # "likeCnt": "like_cnt",
  31. # "shareCnt": "share_cnt",
  32. # "collectionCnt": "collection_cnt",
  33. # "commentCnt": "comment_cnt",
  34. # "strategyType": "strategy"
  35. # }
  36. # for index, i in enumerate(str_list[:-4]):
  37. # if "=" not in i:
  38. # continue
  39. # else:
  40. # key = i.split("=")[0]
  41. # value = i[len(key) + 1:]
  42. # new_key = key_dict.get(key, key)
  43. # video_dict[new_key] = value.replace("null", "")
  44. #
  45. # video_dict['strategy'] = strategy
  46. # video_dict['platform'] = platform
  47. # video_dict['crawler_rule'] = json.dumps({})
  48. # print(json.dumps(video_dict, ensure_ascii=False, indent=4))
  49. # mq = MQ(topic_name="topic_crawler_etl_" + "prod")
  50. # mq.send_msg(video_dict)
  51. video_dict = {'video_title': '吴尊友因病去世!吴老师,您真的不容易,千言万语,汇成一句话您走好❗️', 'video_id': '5262651713', 'duration': 49, 'play_cnt': 71, 'like_cnt': 0, 'comment_cnt': 0, 'share_cnt': 1, 'user_name': '夏日❤️莲莲', 'publish_time_stamp': 1698398572, 'publish_time_str': '2023-10-27 17:22:52', 'video_width': 537, 'video_height': 954, 'avatar_url': 'https://cdn-xphoto2.xiaoniangao.cn/4987933869?Expires=1704038400&OSSAccessKeyId=LTAI4G2W1FsgwzAWYpPoB3v6&Signature=wopOmtlcp9tGyWHYW9uy7DIXO%2Bg%3D&x-oss-process=image%2Fresize%2Cw_200%2Ch_200%2Climit_0%2Finterlace%2C1%2Fquality%2Cq_50%2Fcrop%2Cw_200%2Ch_200%2Cg_center%2Fformat%2Cjpg%2Fauto-orient%2C0', 'profile_id': 55888345, 'profile_mid': 185546, 'cover_url': 'https://cdn-xphoto2.xiaoniangao.cn/5262652619?Expires=1704038400&OSSAccessKeyId=LTAI4G2W1FsgwzAWYpPoB3v6&Signature=qIIRzRICgyv40n3uMFeMwHCY8JY%3D&x-oss-process=image%2Fresize%2Cw_690%2Ch_385%2Climit_0%2Finterlace%2C1%2Fformat%2Cjpg%2Fauto-orient%2C0', 'video_url': 'https://cdn-xalbum2.xiaoniangao.cn/5262651713?Expires=1704038400&OSSAccessKeyId=LTAI5tB7cRkYiqHcTdkVprwb&Signature=hFGFAB49mmgUYwYcF4679bE%2BgLg%3D', 'session': 'xiaoniangao-author-1698402882'}
  52. video_dict['strategy'] = "author"
  53. video_dict['platform'] = "xiaoniangao"
  54. video_dict['user_id'] = 58528269
  55. video_dict['out_video_id'] = video_dict['video_id']
  56. print(json.dumps(video_dict, ensure_ascii=False, indent=4))
  57. mq = MQ(topic_name="topic_crawler_etl_" + "prod")
  58. mq.send_msg(video_dict)