Implemented the return of unique files for storage

This commit is contained in:
Raelon Masters
2019-10-14 17:52:16 -04:00
parent a1bb0aa101
commit f821eb02cb
15 changed files with 87 additions and 76 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/python
import sys
import requests
sys.path.insert(1, 'lib/')
# sys.path.insert(1, 'lib/')
class DuckDuckGo:
@@ -18,8 +18,11 @@ class DuckDuckGo:
try: query = query.string
except AttributeError: query = query
search_result = requests.get(self.url+query+_key)
if search_result.status_code == 200 and search_result.json()['Image'] != '':
try: image_result = search_result.json()['Image']
except ValueError:
image_result = ''
if search_result.status_code == 200 and image_result != '':
image = requests.get(search_result.json()['Image'], stream=True)
image.raw.decode_content = True
return image.raw
else: return False
else: return False