| | |
| | | """ |
| | | # 保存回复视频评论的用户昵称 |
| | | # {"视频名称+发布日期":{"评论用户的昵称":{"评论内容集合"}}} |
| | | import re |
| | | |
| | | import comment_util |
| | | |
| | | __reply_video_comment_user_name_dict = {} |
| | |
| | | __reply_video_comment_user_name_dict[k][comment_nick_name].add(comment_content) |
| | | |
| | | |
| | | def get_replay_content(video_name, video_date, comment_nick_name, comment_content): |
| | | def get_replay_content(video_info, comment_nick_name, comment_content): |
| | | """ |
| | | 获取回复内容 |
| | | :param video_name:视频名称 |
| | | :param video_date:视频日期 |
| | | :param video_info:(视频名称, 日期, 评论次数, 视频标题) |
| | | :param comment_nick_name:评论昵称 |
| | | :param comment_content:评论内容 |
| | | :return: |
| | | """ |
| | | video_name, video_date, video_title = video_info[0], video_info[1], video_info[3] |
| | | |
| | | k = f"{video_name}{video_date}" |
| | | if k not in __reply_video_comment_user_name_dict: |
| | | __reply_video_comment_user_name_dict[k] = {} |
| | |
| | | comment_content = comment_util.replace_img_with_alt(comment_content) |
| | | |
| | | for r in comment_templates: |
| | | if r.match(r[0], comment_content): |
| | | is_match = False |
| | | if r[0].find("【视频标题】") >= 0: |
| | | if comment_content.find(video_title)>=0: |
| | | is_match = True |
| | | elif re.match(r[0], comment_content): |
| | | is_match = True |
| | | if is_match: |
| | | # 能够匹配到正则表达式 |
| | | result = comment_util.load_content(r[1], comment_nick_name, comment_content) |
| | | if result: |
| | |
| | | # 替换评论内容中的img |
| | | comment_content = comment_util.replace_img_with_alt(comment_content) |
| | | for r in like_conditions: |
| | | if r.match(r, comment_content): |
| | | if re.match(r, comment_content): |
| | | # 能够匹配到正则表达式 |
| | | return True |
| | | return False |