Overview
The extraction flow is divided into three independent parts:- Part 1: URL Resolution (short URLs → full URLs)
- Part 2: Video Info Extraction (metadata via yt-dlp)
- Part 3: Media Download (video/images/audio bytes)
ProxySession: Sticky Proxy Pattern
TheProxySession class ensures the same proxy is used across all three parts unless a retry is triggered:
- Proxy is lazily initialized on first
get_proxy()call - Same proxy used across all parts unless
rotate_proxy()is called - Each retry gets a fresh proxy (instant retry with different IP)
Part 1: URL Resolution
Resolves short URLs to full URLs with retry:Part 2: Video Info Extraction
Extracts video metadata using yt-dlp with retry:TikTokDeletedError- Video deleted (status 10204, 10216)TikTokPrivateError- Private video (status 10222)TikTokRegionError- Geo-blocked
TikTokNetworkError- Connection failuresTikTokExtractionError- Extraction failuresTikTokRateLimitError- Rate limiting
Part 3: Media Download
Downloads actual media bytes (video, images, or audio) with retry:Video Download
Slideshow Download (Individual Image Retry)
For slideshows, each image is retried independently:Retry Flow Example
Configuration Summary
All retry limits are configurable via environment variables:data/config.py:
Benefits of 3-Part Strategy
- Independent retry counters - Each stage gets full retry budget
- Instant retry - Proxy rotation = different IP, no backoff needed
- Bandwidth efficiency - Don’t re-download video if only info extraction failed
- Granular image retry - Slideshows retry per-image, not entire batch
- Sticky proxy - Same proxy across parts unless failure (reduces proxy churn)
- Permanent error detection - Don’t waste retries on deleted/private videos
Related Components
- Proxy Rotation - How proxies are selected and rotated
- Media Processing - What happens after successful download
- Source:
tiktok_api/client.py:640-1360(retry methods)

