From 806aa452c3272b8044a42f82c3511842b074feb9 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sun, 27 Mar 2016 15:58:39 +0200 Subject: [PATCH] Made the downloader aware of size issues when copying the wrong URL --- downloader.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/downloader.py b/downloader.py index 7703ec4..79db947 100755 --- a/downloader.py +++ b/downloader.py @@ -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: