From 6e37ef5d4f3f9690930ae4c00d84ec0cc5ae466c Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Sun, 26 Jan 2020 22:12:43 +0900 Subject: [PATCH] Implement function to check duplication of chat --- pytchat/tool/downloader.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pytchat/tool/downloader.py b/pytchat/tool/downloader.py index e79c36d..db662f4 100644 --- a/pytchat/tool/downloader.py +++ b/pytchat/tool/downloader.py @@ -250,3 +250,25 @@ class Downloader: .remove_duplicate_tail() .combine() ) + +def check_duplicate(blocks): + + def is_same_offset(index): + offset_0 = parser.get_offset(blocks[index]) + offset_1 = parser.get_offset(blocks[index+1]) + return (offset_0 == offset_1) + + def is_same_id(index): + id_0 = parser.get_id(blocks[index]) + id_1 = parser.get_id(blocks[index+1]) + return (id_0 == id_1) + + def is_same_type(index): + type_0 = parser.get_type(blocks[index]) + type_1 = parser.get_type(blocks[index+1]) + return (type_0 == type_1) + ret =[] + for i in range(len(blocks)-1): + if ( is_same_offset(i) and is_same_id(i) and is_same_type(i) ): + ret.append(blocks[i]) + return ret \ No newline at end of file