Skip to content

Commit

Permalink
Merge pull request #37 from Datalux/fix/following-private-profiles
Browse files Browse the repository at this point in the history
fix: access to profile if you following target
  • Loading branch information
Datalux authored Aug 28, 2020
2 parents f614449 + 339b717 commit 3fc20e5
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions src/Osintgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Osintgram:
user_id = None
target_id = None
is_private = True
following = False
target = ""
writeFile = False
jsonDump = False
Expand All @@ -39,6 +40,7 @@ def setTarget(self, target):
user = self.get_user(target)
self.target_id = user['id']
self.is_private = user['is_private']
self.following = self.check_following()
self.__printTargetBanner__()

def __getUsername__(self):
Expand Down Expand Up @@ -96,7 +98,13 @@ def __printTargetBanner__(self):
pc.printout(str(self.target), pc.CYAN)
pc.printout(" [" + str(self.target_id) + "] ")
if self.is_private:
pc.printout("[PRIVATE PROFILE]", pc.RED)
pc.printout("[PRIVATE PROFILE]", pc.BLUE)
if self.following:
pc.printout(" [FOLLOWING]", pc.GREEN)
else:
pc.printout(" [NOT FOLLOWING]", pc.RED)


print('\n')

def change_target(self):
Expand All @@ -106,8 +114,7 @@ def change_target(self):
return

def get_addrs(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target localizations...\n")
Expand All @@ -117,7 +124,7 @@ def get_addrs(self):
locations = {}

for post in data:
if post['location'] is not None:
if 'location' in post and post['location'] is not None:
lat = post['location']['lat']
lng = post['location']['lng']
locations[str(lat) + ', ' + str(lng)] = post.get('taken_at')
Expand Down Expand Up @@ -173,8 +180,7 @@ def get_addrs(self):
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_captions(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target captions...\n")
Expand Down Expand Up @@ -232,8 +238,7 @@ def get_captions(self):
return

def get_total_comments(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target total comments...\n")
Expand Down Expand Up @@ -266,8 +271,7 @@ def get_total_comments(self):
pc.printout(" comments in " + str(posts) + " posts\n")

def get_followers(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target followers...\n")
Expand Down Expand Up @@ -319,8 +323,7 @@ def get_followers(self):
print(t)

def get_followings(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target followings...\n")
Expand Down Expand Up @@ -372,8 +375,7 @@ def get_followings(self):
print(t)

def get_hashtags(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target hashtags...\n")
Expand Down Expand Up @@ -481,8 +483,7 @@ def get_user_info(self):
sys.exit(2)

def get_total_likes(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target total likes...\n")
Expand Down Expand Up @@ -515,8 +516,7 @@ def get_total_likes(self):
pc.printout(" likes in " + str(posts) + " posts\n")

def get_media_type(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target captions...\n")
Expand Down Expand Up @@ -564,8 +564,7 @@ def get_media_type(self):
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_people_who_commented(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for users who commented...\n")
Expand Down Expand Up @@ -623,8 +622,7 @@ def get_people_who_commented(self):
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_photo_description(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

content = urllib.request.urlopen("https://www.instagram.com/" + str(self.target) + "/?__a=1")
Expand Down Expand Up @@ -673,8 +671,7 @@ def get_photo_description(self):
pc.printout("Sorry! No results found :-(\n", pc.RED)

def get_user_photo(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

limit = -1
Expand Down Expand Up @@ -764,8 +761,7 @@ def get_user_propic(self):
sys.exit(2)

def get_user_stories(self):
if self.is_private:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
if self.check_private_profile():
return

pc.printout("Searching for target stories...\n")
Expand Down Expand Up @@ -968,3 +964,14 @@ def onlogin_callback(self, api, new_settings_file):
with open(new_settings_file, 'w') as outfile:
json.dump(cache_settings, outfile, default=self.to_json)
#print('SAVED: {0!s}'.format(new_settings_file))

def check_following(self):
endpoint = 'users/{user_id!s}/full_detail_info/'.format(**{'user_id': self.target_id})
return self.api._call_api(endpoint)['user_detail']['user']['friendship_status']['following']

def check_private_profile(self):
if self.is_private and not self.following:
pc.printout("Impossible to execute command: user has private profile\n", pc.RED)
return True
return False

0 comments on commit 3fc20e5

Please # to comment.