Made the downloader aware of size issues when copying the wrong URL
This commit is contained in:
parent
faf874f519
commit
806aa452c3
1 changed files with 8 additions and 9 deletions
|
@ -8,15 +8,12 @@ def fileDownloader(url, sender = False):
|
|||
filename = "%s/%s" % (sender, url.split('/')[-1])
|
||||
else:
|
||||
filename = url.split('/')[-1]
|
||||
if not os.path.isfile(filename):
|
||||
remote = requests.get(url, stream=True)
|
||||
with open(filename, 'wb') as outfile:
|
||||
for chunk in remote.iter_content(chunk_size=1024):
|
||||
if chunk:
|
||||
outfile.write(chunk)
|
||||
outfile.flush()
|
||||
else:
|
||||
print("File %s already exists. Skipping.", file=sys.stderr)
|
||||
remote = requests.get(url, stream=True)
|
||||
with open(filename, 'wb') as outfile:
|
||||
for chunk in remote.iter_content(chunk_size=1024):
|
||||
if chunk:
|
||||
outfile.write(chunk)
|
||||
outfile.flush()
|
||||
|
||||
def urlparse(url):
|
||||
if "/img/usr/" in url:
|
||||
|
@ -40,6 +37,8 @@ if __name__ == "__main__":
|
|||
except ValueError:
|
||||
print("%s is not a valid URL. Skipping." % url, file=sys.stderr)
|
||||
else:
|
||||
if purl == urlparse(url):
|
||||
print("Notice: You may have copied the image URL rather than the link URL from the message window. Use the link URL instead!")
|
||||
if args.get_urls:
|
||||
print(purl)
|
||||
elif args.sender:
|
||||
|
|
Loading…
Reference in a new issue