- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| downloader.py | ||
| README.md | ||
| requirements.txt | ||
Website Media Downloader
A simple script that asks you for a URL and downloads the media it finds into a folder that mirrors the site's address, rooted in the current working directory (wherever you run the script from).
./example.com/blog/my-post/
What it does
- Prompts for a URL (loops until you press Enter on an empty line).
- Direct media links (
.jpg,.mp4,.mp3,.pdf, …) are downloaded as-is. - Web pages are scraped for
<img>(incl.srcset),<video>,<audio>,<source>,<embed>,og:image, and any<a>pointing at a media file. - yt-dlp runs as a fallback, so videos on YouTube, Vimeo, X/Twitter and ~1000 other sites are captured too.
- Skips files it already downloaded (matched by name + size), adds
-1,-2suffixes on real collisions, and uses.partfiles so an interrupted download never leaves a broken file behind.
Install
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
Dependencies: requests, beautifulsoup4, yt-dlp.
(yt-dlp is optional but recommended — without it only plain
<video>/<audio>/<img> tags are grabbed.)
Then run it as .venv/bin/python downloader.py, or activate the venv first
with source .venv/bin/activate.
Usage
Interactive — the script asks for a URL:
.venv/bin/python downloader.py
Non-interactive — pass the URL as an argument:
.venv/bin/python downloader.py https://example.com/blog/my-post
Where files land
The target folder mirrors the URL after https://, with www. stripped:
| URL | Folder |
|---|---|
https://example.com/blog/my-post |
./example.com/blog/my-post/ |
https://www.example.com/ |
./example.com/ |
https://example.com/img/photo.jpg |
./example.com/img/ |
https://example.com/blog/post.html |
./example.com/blog/post/ |
https://example.com/blog/index.html |
./example.com/blog/ |
The trailing filename is dropped: a media file is saved inside its parent
folder, and a page name like post.html becomes the folder name itself.
The ./ root is the directory you launch the script from — cd to your media
folder first, otherwise the folders appear wherever you happen to run it.
Notes
- One broken asset won't abort the run — failures are listed in the summary.
- If a page has no video but yt-dlp still runs, you'll see
yt-dlp: no video found on this page; that's normal. - Sites that block scrapers may return errors regardless of settings.