Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heirarchy in output folder (based on target) #538

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Osintgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def setTarget(self, target, show_output):
self.following = self.check_following()
if(show_output):
self.__printTargetBanner__()

def create_target_output_directory(self):
# Create directory for target (if absent)
user_output_dir = self.output_dir + "/" + self.target
if not os.path.exists(user_output_dir):
os.mkdir(user_output_dir)
return user_output_dir

def __get_feed__(self):
data = []
Expand Down Expand Up @@ -883,14 +890,16 @@ def get_user_photo(self):
next_max_id = results.get('next_max_id')

try:
target_output_directory = self.create_target_output_directory()

for item in data:
if counter == limit:
break
if "image_versions2" in item:
counter = counter + 1
url = item["image_versions2"]["candidates"][0]["url"]
photo_id = item["id"]
end = self.output_dir + "/" + self.target + "_" + photo_id + ".jpg"
end = target_output_directory + "/" + photo_id + ".jpg"
urllib.request.urlretrieve(url, end)
sys.stdout.write("\rDownloaded %i" % counter)
sys.stdout.flush()
Expand All @@ -902,7 +911,7 @@ def get_user_photo(self):
counter = counter + 1
url = i["image_versions2"]["candidates"][0]["url"]
photo_id = i["id"]
end = self.output_dir + "/" + self.target + "_" + photo_id + ".jpg"
end = target_output_directory + "/" + photo_id + ".jpg"
urllib.request.urlretrieve(url, end)
sys.stdout.write("\rDownloaded %i" % counter)
sys.stdout.flush()
Expand Down