Skip to content

Instantly share code, notes, and snippets.

@Ridley-nelson17
Created May 8, 2023 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ridley-nelson17/435b594950f5173d337e98bd5a7553c9 to your computer and use it in GitHub Desktop.
Save Ridley-nelson17/435b594950f5173d337e98bd5a7553c9 to your computer and use it in GitHub Desktop.
A mass file downloader written in only five lines. It could be shrunk and improved but I made this at 3:01AM
import os, urllib.request
from urllib.parse import urlsplit
LINK_FILE, links, filter, download = 'links.txt', [], (lambda l=None: links.append(l.replace('\n', '')) if l != "" or l != "\n" else None), (lambda url=None: urllib.request.urlretrieve(url, os.path.basename(urlsplit(url).path)) if url != None else None)
for line in open(os.path.join(os.getcwd(), LINK_FILE), 'w+').readlines(): filter(line)
for l in links: download(l)
@Ridley-nelson17
Copy link
Author

TODO (on a rainy day): implement duplicate file handling, error redirection, and possibly a simple UXUI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment