mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Implemented the return of unique files for storage
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user