Pinchana TikTok
This FastAPI module extracts supported public TikTok posts through a dedicated yt-dlp workflow. It handles ordinary videos and photo slideshows, including slideshow background audio when available.
Processing flow
- Resolve short TikTok URLs (
vm.tiktok.com,vt.tiktok.com,www.tiktok.com/t/, andwww.tt.site/t/) with bounded, validated HTTP redirects, without downloading the destination page. This works independently ofTIKTOK_DIRECT_WEB_PRIMARY; barett.sitelinks are requested throughwww.tt.site. On att.sitetransport failure or HTTP 5xx, try the same code once throughvm.tiktok.com, within the same three-request limit. HTTP 5xx failures are treated as temporary upstream outages, not extraction/parser failures. - When
TIKTOK_DIRECT_WEB_PRIMARYis enabled, extract ordinary videos from the canonical page's hydration payload in one metadata request and use its direct CDN mirrors. - Use TikTok's anonymous player endpoint as the primary photo-post path and as the established video fallback; retain TikTok playback-host rewrites as a final media fallback.
- Reuse anonymous cookies, pace independent scrape jobs globally, and retry temporary failures within a bounded policy.
- When the deployment-wide VPN is enabled, rotate Gluetun once after a confirmed platform block.
- Download ordered media to
/app/cache/tiktok/{post_id}in containers.
The gateway's API v1 response represents slideshow images as ordered content assets and their audio as a soundtrack asset.
API
POST /scrapeaccepts{"url":"https://www.tiktok.com/@account/video/POST_ID"}or a supported short link such as{"url":"https://www.tt.site/t/SHORT_CODE/"}.GET /healthreports module and VPN readiness.
External clients should call the gateway's authenticated POST /v1/scrape route.
Configuration
| Variable | Default | Purpose |
|---|---|---|
CACHE_PATH |
./cache |
Base media cache path |
CACHE_MAX_SIZE_GB |
10.0 |
Maximum cache size before eviction |
YTDLP_CONCURRENCY |
1 |
Maximum concurrent yt-dlp operations |
TIKTOK_DIRECT_WEB_PRIMARY |
false |
Enable one-page video extraction (short URL resolution is always enabled) |
TIKTOK_REQUEST_INTERVAL_SECONDS |
2.0 |
Minimum delay between independent TikTok job starts |
TIKTOK_INTERNAL_REQUEST_INTERVAL_SECONDS |
0 |
Optional delay between requests inside one job; keep 0 unless block-rate data requires it |
TIKTOK_RETRY_DELAY_SECONDS |
2.0 |
Delay before retrying a web challenge with a fresh anonymous session |
TIKTOK_FORMAT_ATTEMPTS |
3 |
Maximum watermark-free video formats attempted before refreshing media URLs |
TIKTOK_TRANSCODE_HEVC |
false |
Optionally convert HEVC HD renditions to H.264 for legacy clients; native Telegram apps normally do not need this |
TIKTOK_HEVC_TRANSCODE_TIMEOUT_SECONDS |
180 |
Maximum time allowed for an HEVC compatibility conversion |
TIKTOK_VPN_ROTATION_COOLDOWN_SECONDS |
30 |
Minimum delay between TikTok-triggered Gluetun reconnects |
TIKTOK_PROXY_URL |
empty | Optional HTTP/SOCKS proxy applied to extraction and every media download |
GLUETUN_CONTROL_URL |
http://localhost:8000 |
Private Gluetun control endpoint |
Development
uv sync --frozen
uv run uvicorn pinchana_tiktok.main:app --host 0.0.0.0 --port 8081 --reload
# Run from the repository root.
docker build --file scrapers/pinchana-tiktok/Dockerfile --tag pinchana-tiktok:local .
Development Compose keeps VPN_ENABLED=false. VPN operation is controlled only
by the deployment-wide VPN_ENABLED setting; there is no TikTok-specific VPN
toggle. The scraper supports anonymous public posts only and does not accept
account cookies, fabricated mobile identifiers, or CAPTCHA-solving services.
Live tests are opt-in. Set PINCHANA_TIKTOK_LIVE=1 and provide the four
TIKTOK_LIVE_*_URL values documented in .env.example before running pytest.
Quiet video audio is measured and raised toward -14 LUFS using FFmpeg's
loudness filter with a -1 dB true-peak target. The video stream is copied,
and videos already at the target level or without audio are left unchanged.
Set TIKTOK_NORMALIZE_AUDIO=false in the scraper environment to disable this.
Metadata
Release files for pinchana-tiktok 26.11.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pinchana_tiktok-26.11.15.tar.gz | 24.4 kB | With provenance | Details for pinchana_tiktok-26.11.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pinchana_tiktok-26.11.15-py3-none-any.whl | Python 3 | none | any | Details for pinchana_tiktok-26.11.15-py3-none-any.whl |
Total release size: 51.0 kB
Release files / pinchana_tiktok-26.11.15.tar.gz
| Download URL | pinchana_tiktok-26.11.15.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7cb86e02792201b8d4a683bdeb96a7d5a2c8d5c8b5e0f16436fbe2d434b1889
|
|
BLAKE2b-256 checksum How to use checksums |
7575da88c45cf1fc6da5c230590b8ebd5dc4758ad5b4c20d9c9ae380364c6e28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / pinchana_tiktok-26.11.15-py3-none-any.whl
| Download URL | pinchana_tiktok-26.11.15-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebdae912e7ef6c02169005ae2397125afa58c877be123ae2942153dea42c79ec
|
|
BLAKE2b-256 checksum How to use checksums |
fd8b9f5ab17a74f9d42eddb8b503cfbafd64b01c7e82fa189b681f4213f91410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for pinchana-tiktok 26.11.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pinchana_tiktok-26.11.15.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.