From 274e2cf884f164fce35c39518b9b32eae7e3877a Mon Sep 17 00:00:00 2001 From: Sagar Badiyani Date: Sat, 25 Jun 2022 22:27:31 +0530 Subject: [PATCH] Initial Commit --- main.py | 1 + src/Osintgram.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/main.py b/main.py index c5864eee..40d74a16 100644 --- a/main.py +++ b/main.py @@ -154,6 +154,7 @@ def _quit(): 'stories': api.get_user_stories, 'tagged': api.get_people_tagged_by_user, 'target': api.change_target, + 'views': api.get_total_views, 'wcommented': api.get_people_who_commented, 'wtagged': api.get_people_who_tagged } diff --git a/src/Osintgram.py b/src/Osintgram.py index 7abe11d6..11c82269 100644 --- a/src/Osintgram.py +++ b/src/Osintgram.py @@ -624,6 +624,35 @@ def get_total_likes(self): pc.printout(str(like_counter), pc.MAGENTA) pc.printout(" likes in " + str(posts) + " posts\n") + def get_total_views(self): + if self.check_private_profile(): + return + + pc.printout(f'Searching for {self.target} total views...\n') + + data = self.__get_feed__() + + total_number_of_views = sum(list(map(lambda x: x.get('view_count', 0), data))) + total_number_of_posts = len(data) + + if self.writeFile: + file_name = f'{self.output_dir}/{self.target}_views.txt' + file = open(file_name, "w") + file.write(f'{total_number_of_views} views in {total_number_of_posts} posts\n') + file.close() + + if self.jsonDump: + json_data = { + 'view_counter': total_number_of_views, + 'posts': total_number_of_posts + } + json_file_name = f'{self.output_dir}/{self.target}_views.json' + with open(json_file_name, 'w') as f: + json.dump(json_data, f) + + pc.printout(f'{total_number_of_views}', pc.MAGENTA) + pc.printout(f' views in {total_number_of_posts} posts\n') + def get_media_type(self): if self.check_private_profile(): return