From ce5ae11eb11de864e919186fe759555978fab065 Mon Sep 17 00:00:00 2001 From: Datalux Date: Wed, 27 May 2020 10:52:45 +0200 Subject: [PATCH 1/4] feat: add getUserStories command --- Osintgram.py | 20 +++++++++++++++++++- main.py | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Osintgram.py b/Osintgram.py index 214a40bf..3f0b68b9 100644 --- a/Osintgram.py +++ b/Osintgram.py @@ -694,4 +694,22 @@ def getUserPropic(self): pc.printout("Target propic saved in output folder\n", pc.GREEN) else: - pc.printout("Sorry! No results found :-(\n", pc.RED) \ No newline at end of file + pc.printout("Sorry! No results found :-(\n", pc.RED) + + + def getUserStories(self, id): + endpoint = 'feed/user/{id!s}/story/'.format(**{'id': id}) + content = self.api.SendRequest(endpoint) + data = self.api.LastJson['reel']['items'] + + # for debug + with open('data2.json', 'w') as outfile: + json.dump(data, outfile) + + for i in data: + story_id = i["id"] + if i["media_type"] == 1: # it's a photo + url = i['image_versions2']['candidates'][0]['url'] + end = "output/" + self.target + "_" + story_id + ".jpg" + urllib.request.urlretrieve(url, end) + diff --git a/main.py b/main.py index 34107b31..1ea17b2b 100644 --- a/main.py +++ b/main.py @@ -54,6 +54,8 @@ def cmdlist(): print("Get target's posts type (photo or video)") pc.printout("propic\t\t") print("Download target's profile picture") + pc.printout("stories\t\t") + print("Download target's sories") printlogo() @@ -105,7 +107,9 @@ def cmdlist(): elif cmd == "mediatype": api.getMediaType(id) elif cmd == "propic": - api.getUserPropic() + api.getUserPropic() + elif cmd == "stories": + api.getUserStories(id) else: pc.printout("Unknown command\n", pc.RED) From c4b0cda296febcf60e9e30c71539d196a616dbc9 Mon Sep 17 00:00:00 2001 From: Datalux Date: Thu, 28 May 2020 08:55:34 +0200 Subject: [PATCH 2/4] chore: added verbosity --- Osintgram.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Osintgram.py b/Osintgram.py index 3f0b68b9..9932937c 100644 --- a/Osintgram.py +++ b/Osintgram.py @@ -698,18 +698,30 @@ def getUserPropic(self): def getUserStories(self, id): + pc.printout("Searching for target stories...\n") + endpoint = 'feed/user/{id!s}/story/'.format(**{'id': id}) content = self.api.SendRequest(endpoint) - data = self.api.LastJson['reel']['items'] + data = self.api.LastJson #['reel']['items'] + counter = 0 # for debug - with open('data2.json', 'w') as outfile: + with open('data3.json', 'w') as outfile: json.dump(data, outfile) - for i in data: - story_id = i["id"] - if i["media_type"] == 1: # it's a photo - url = i['image_versions2']['candidates'][0]['url'] - end = "output/" + self.target + "_" + story_id + ".jpg" - urllib.request.urlretrieve(url, end) + if data['reel'] != None: #no stories avaibile + for i in data['reel']['items']: + story_id = i["id"] + if i["media_type"] == 1: # it's a photo + url = i['image_versions2']['candidates'][0]['url'] + end = "output/" + self.target + "_" + story_id + ".jpg" + urllib.request.urlretrieve(url, end) + counter += 1 + + if counter > 0: + pc.printout(str(counter) + " target stories saved in output folder\n", pc.GREEN) + else: + pc.printout("Sorry! No results found :-(\n", pc.RED) + + From bc7718dac202b45e4404cd97577d1e5bf8a57051 Mon Sep 17 00:00:00 2001 From: Datalux Date: Thu, 28 May 2020 09:09:01 +0200 Subject: [PATCH 3/4] feat: added video and gif support --- Osintgram.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Osintgram.py b/Osintgram.py index 9932937c..0f6d9821 100644 --- a/Osintgram.py +++ b/Osintgram.py @@ -702,14 +702,14 @@ def getUserStories(self, id): endpoint = 'feed/user/{id!s}/story/'.format(**{'id': id}) content = self.api.SendRequest(endpoint) - data = self.api.LastJson #['reel']['items'] + data = self.api.LastJson counter = 0 # for debug with open('data3.json', 'w') as outfile: json.dump(data, outfile) - if data['reel'] != None: #no stories avaibile + if data['reel'] != None: # no stories avaibile for i in data['reel']['items']: story_id = i["id"] if i["media_type"] == 1: # it's a photo @@ -717,6 +717,12 @@ def getUserStories(self, id): end = "output/" + self.target + "_" + story_id + ".jpg" urllib.request.urlretrieve(url, end) counter += 1 + + elif i["media_type"] == 2: # it's a gif or video + url = i['video_versions'][0]['url'] + end = "output/" + self.target + "_" + story_id + ".mp4" + urllib.request.urlretrieve(url, end) + counter += 1 if counter > 0: pc.printout(str(counter) + " target stories saved in output folder\n", pc.GREEN) From d89166fb4e8c17dabf23826b02938cc10b3add01 Mon Sep 17 00:00:00 2001 From: Datalux Date: Thu, 28 May 2020 09:09:35 +0200 Subject: [PATCH 4/4] refactor: removed debug log --- Osintgram.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Osintgram.py b/Osintgram.py index 0f6d9821..6b5f59c2 100644 --- a/Osintgram.py +++ b/Osintgram.py @@ -705,10 +705,6 @@ def getUserStories(self, id): data = self.api.LastJson counter = 0 - # for debug - with open('data3.json', 'w') as outfile: - json.dump(data, outfile) - if data['reel'] != None: # no stories avaibile for i in data['reel']['items']: story_id = i["id"]