Skip to content

Commit

Permalink
Added a sample config file and made metadata export to a json (hardik…
Browse files Browse the repository at this point in the history
…vasa#132)

* Added sample config & export to json instead of txt

* Fixed typo

* Added logs to .gitignore
  • Loading branch information
neon-cyan authored and hardikvasa committed Aug 11, 2018
1 parent 368de9d commit d05d061
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ output/

# Downloads
downloads/

# Logs
logs/
8 changes: 4 additions & 4 deletions google_images_download/google_images_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,16 +843,16 @@ def download(self,arguments):
items,errorCount,abs_path = self._get_all_items(raw_html,main_directory,dir_name,limit,arguments) #get all image items and download images
paths[pky + search_keyword[i] + sky] = abs_path

#dumps into a text file
#dumps into a json file
if arguments['extract_metadata']:
try:
if not os.path.exists("logs"):
os.makedirs("logs")
except OSError as e:
print(e)
text_file = open("logs/"+search_keyword[i]+".txt", "w")
text_file.write(json.dumps(items, indent=4, sort_keys=True))
text_file.close()
json_file = open("logs/"+search_keyword[i]+".json", "w")
json.dump(items, json_file, indent=4, sort_keys=True)
json_file.close()

#Related images
if arguments['related_images']:
Expand Down
16 changes: 16 additions & 0 deletions google_images_download/sample_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Records": [
{
"keywords": "apple",
"limit": 5,
"color": "green",
"print_urls": true
},
{
"keywords": "universe",
"limit": 15,
"size": "large",
"print_urls": true
}
]
}

0 comments on commit d05d061

Please sign in to comment.