Rework downloader: single yt-dlp call, reliable file paths, better CLI

- Download each post with one yt-dlp run and take the saved file paths
  from yt-dlp's own output instead of parsing logs or guessing by mtime
- Let yt-dlp build and sanitize filenames (same naming as before) and
  read its output as UTF-8 so non-ASCII uploader names work on Windows
- Rewrite /photo/ URLs to /video/, strip query strings, accept
  vm./vt.tiktok.com short links, and require a real tiktok.com host
- Stop duplicating entries in failed.txt and remove URLs from it once
  they download successfully
- Raise DownloadError with yt-dlp's short error line; add retries and
  timeouts
- CLI: multiple URLs/files, comments in input files, --delay, --force,
  -v, non-zero exit code on failures; settings via environment/.env
This commit is contained in:
X4Lo committed 2026-11-15 22:37:58 +00:00
1 parent 7c71ed6df8
commit 1c17487ce4
2 files changed
+345 -277

No files matched your search

+12 -1
View File
@@ -30,10 +30,21 @@ python downloader.py https://www.tiktok.com/@user/video/123456789
# Batch download from a file (one URL per line)
python downloader.py in/my-urls.txt
# Retry previously failed downloads
# Retry previously failed downloads (successes are removed from failed.txt)
python downloader.py failed.txt
# Mix URLs and files; short links (vm.tiktok.com / vt.tiktok.com) work too
python downloader.py https://vm.tiktok.com/ZMabc123/ in/more-urls.txt
# Options: --delay SECONDS, --force (ignore downloaded_ids.txt), -v (show yt-dlp output on errors)
```
Input files may contain blank lines, `# comments`, and URLs mixed with other text.
The exit code is non-zero when any download fails.
Optional environment variables (or `.env`): `YT_DLP_PATH`, `TIKDOWN_DOWNLOAD_DIR`,
`TIKDOWN_COOKIES` (cookies.txt for private posts), `TIKDOWN_DELAY`.
## Downloads
Videos and photos are saved to `./downloads/`. Filenames include the upload date when metadata is available: