mirror of
https://github.com/saurabhan/Wallhaven-dl.git
synced 2026-01-07 10:28:02 +00:00
Added check if file exist
This commit is contained in:
@@ -66,7 +66,7 @@ def category():
|
||||
sketchy - For 'Sketchy'
|
||||
nsfw - For 'Not Safe For Work'
|
||||
ws - For 'SFW' and 'Sketchy'
|
||||
wn - for 'SFW' and 'NSFW'
|
||||
wn - For 'SFW' and 'NSFW'
|
||||
sn - For 'Sketchy' and 'NSFW'
|
||||
all - For 'SFW', 'Sketchy' and 'NSFW'
|
||||
****************************************************************
|
||||
@@ -131,14 +131,16 @@ def main():
|
||||
i]
|
||||
for ext in imgext:
|
||||
iurl = url + ext
|
||||
osPath = os.path.join('Wallhaven', os.path.basename(iurl))
|
||||
if not os.path.exists(osPath):
|
||||
imgreq = requests.get(iurl, cookies=cookies)
|
||||
if imgreq.status_code == 200:
|
||||
print('Downloading: ' + iurl)
|
||||
with open(os.path.join('Wallhaven', os.path.basename(iurl)), 'ab') as imageFile:
|
||||
for chunk in tqdm.tqdm(imgreq.iter_content(1024), total=(int(imgreq.headers['content-length']) / 1024), unit='KB'):
|
||||
time.sleep(0.01)
|
||||
with open(osPath, 'ab') as imageFile:
|
||||
for chunk in imgreq.iter_content(1024):
|
||||
imageFile.write(chunk)
|
||||
break
|
||||
else:
|
||||
print("%s already exist" % os.path.basename(iurl))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user