Skip to content

Commit

Permalink
Merge pull request #7 from Datalux/refactor/old-comments
Browse files Browse the repository at this point in the history
refactor: removed old comments
  • Loading branch information
Datalux authored May 27, 2020
2 parents e6f26a7 + 555578a commit d0752ca
Showing 1 changed file with 39 additions and 70 deletions.
109 changes: 39 additions & 70 deletions Osintgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ def __getPassword__(self):
return p

def __getAdressesTimes__(self, id):
only_id = {} #var only for max_next_id parameter | pagination
photos = [] # only photos
a = None #helper
only_id = {}
photos = []
a = None
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson
else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

Expand All @@ -65,7 +65,7 @@ def __getAdressesTimes__(self, id):

locations = {}

for i in photos: #extract location from photos, related
for i in photos:
for j in i:
if 'lat' in j.keys():
lat = j.get('lat')
Expand All @@ -75,12 +75,12 @@ def __getAdressesTimes__(self, id):

address = {}
for k,v in locations.items():
details = self.geolocator.reverse(k) #locate for key
unix_timestamp = datetime.datetime.fromtimestamp(v) # read timestamp as a value
details = self.geolocator.reverse(k)
unix_timestamp = datetime.datetime.fromtimestamp(v)
address[details.address] = unix_timestamp.strftime('%Y-%m-%d %H:%M:%S')


sort_addresses = sorted(address.items(), key=lambda p: p[1], reverse=True) #sorting
sort_addresses = sorted(address.items(), key=lambda p: p[1], reverse=True)

return sort_addresses

Expand Down Expand Up @@ -136,27 +136,26 @@ def getHashtags(self, id):

text = []
only_id = {}
a = None #helper
a = None
hashtags = []
counter = 1
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson
with open('data.json', 'w') as outfile:
json.dump(only_id, outfile)

else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

try:
for i in a:
c = i.get('caption', {}).get('text')
text.append(c)
#print str(counter) + ' ' + c
counter = counter +1
except AttributeError:
pass
Expand Down Expand Up @@ -197,15 +196,15 @@ def getTotalLikes(self, id):

like_counter = 0
only_id = {}
a = None #helper
a = None
counter = 0
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson
else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']
try:
Expand Down Expand Up @@ -233,15 +232,15 @@ def getTotalComments(self, id):

comment_counter = 0
only_id = {}
a = None #helper
a = None
counter = 0
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson
else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']
try:
Expand Down Expand Up @@ -272,19 +271,19 @@ def getPeopleTaggedByUser(self, id):
full_name = []
post = []
only_id = {}
a = None #helper
a = None
counter = 1
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
a = self.api.LastJson['items']
with open('jj.json', 'w') as outfile:
json.dump(a, outfile)
only_id = self.api.LastJson #all LastJson with max_id param
only_id = self.api.LastJson


else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

Expand Down Expand Up @@ -495,16 +494,16 @@ def getUserPhoto(self, id):
return


a = None #helper
a = None
counter = 0
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson

else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

Expand Down Expand Up @@ -551,17 +550,17 @@ def getUserPhoto(self, id):
def getCaptions(self, id):
pc.printout("Searching for target captions...\n")

a = None #helper
a = None
counter = 0
captions = []
while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson

else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

Expand Down Expand Up @@ -611,19 +610,19 @@ def getCaptions(self, id):
def getMediaType(self, id):
pc.printout("Searching for target captions...\n")

a = None #helper
a = None
counter = 0
photo_counter = 0
video_counter = 0

while True:
if (a == None):
self.api.getUserFeed(id)
a = self.api.LastJson['items']#photos 00, 01, 02...
only_id = self.api.LastJson #all LastJson with max_id param
a = self.api.LastJson['items']
only_id = self.api.LastJson

else:
self.api.getUserFeed(id, only_id['next_max_id']) #passing parameter max_id
self.api.getUserFeed(id, only_id['next_max_id'])
only_id = self.api.LastJson
a = self.api.LastJson['items']

Expand Down Expand Up @@ -695,34 +694,4 @@ def getUserPropic(self):
pc.printout("Target propic saved in output folder\n", pc.GREEN)

else:
pc.printout("Sorry! No results found :-(\n", pc.RED)






























pc.printout("Sorry! No results found :-(\n", pc.RED)

0 comments on commit d0752ca

Please sign in to comment.