def __init__(self, comment_object): # コメントID self.id = str(comment_object["no"]) # スレッド self.thread = comment_object["thread"] # コマンド self.mail = comment_object.get("mail", "") # コメント投稿者ユーザID self.posted_by = comment_object.get("user_id", "") # コメント投稿日時 self.posted_at = datetime.fromtimestamp(comment_object["date"]) # コメントが投稿された動画内時点 self.point = Util.translate_seconds_to_video_time_point( comment_object["vpos"] / 100) # 公式ニコられ数 self.official_nicoru = int(comment_object.get("nicoru", 0)) # 削除されているか self.was_deleted = bool(comment_object.get("deleted")) # コメント内容 self.text = "このコメントは削除されました" if self.was_deleted else html.escape( comment_object["content"])
def test(self): assert Util.translate_seconds_to_video_time_point( 114514) == '1908:34'
def __get_params_for_comment(self, video_api_info: VideoAPIInfo): """make parameters to get comment :param video_api_info: VideoAPIInfo :return: parameter dict """ video_info = self.get_video_info(video_api_info.video_id) commented_point = Util.get_commented_point(video_info.length) params = [ { "thread": { "language": 0, "nicoru": 1, "scores": 1, "thread": str(video_api_info.thread_id), "user_id": video_api_info.user_id, "userkey": video_api_info.user_key, "version": '20090904', "with_global": 1, } }, { "thread_leaves": { "content": "{}:100,1000".format(commented_point), "language": 0, "nicoru": 1, "scores": 1, "thread": str(video_api_info.thread_id), "user_id": video_api_info.user_id, "userkey": video_api_info.user_key, }, } ] thread_key, force_184 = self.__get_thread_key(video_api_info.thread_id) if thread_key: # for official video and the like params.append({ "thread": { "force_184": force_184, "language": 0, "nicoru": 1, "scores": 1, "thread": str(video_api_info.thread_id), "threadkey": thread_key, "user_id": video_api_info.user_id, "version": '20090904', "with_global": 1, } }) params.append({ "thread_leaves": { "content": "{}:100,1000".format(commented_point), "force_184": force_184, "language": 0, "nicoru": 1, "scores": 1, "thread": str(video_api_info.thread_id), "threadkey": thread_key, "user_id": video_api_info.user_id, }, }) return params
def get_commented_point(video_length: str): return "0-" + Util.get_minute_from_video_time_point(video_length)
def test(self): assert Util.get_block_no(298) == 2 assert Util.get_block_no(299) == 3 assert Util.get_block_no(300) == 3
def test(self): assert Util.get_commented_point('1145:14') == '0-1146'
def test_irregular(self): assert Util.get_minute_from_video_time_point(':14') == '100'
def test_regular(self): assert Util.get_minute_from_video_time_point('1145:14') == '1146'