Commit 806aa452 authored by Klaus-Uwe Mitterer's avatar Klaus-Uwe Mitterer

Made the downloader aware of size issues when copying the wrong URL

parent faf874f5
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment