Pinchana extracts media and metadata from 13 scraper integrations. Use
pinchana-scraper in a Python script, or run the FastAPI gateway to serve
scrape requests and cached media over HTTP.
Python API · Docker gateway · Supported modules · Development
Use Python 3.13 or newer. Install the bundle for all 13 scrapers under the
pinchana_scraper namespace. Python loads each scraper when you import it.
python -m pip install pinchana-scraperInstall an individual package when you only need one platform. For example,
install pinchana-shorts and use from pinchana_shorts import scrape.
The supported modules table has the command and import
name for each scraper.
python -m pip install pinchana-shortsThis example uses the bundle. Save it as example.py and replace VIDEO_ID
with a YouTube Shorts ID. Bundle guide
import asyncio
from pinchana_scraper import shorts
async def main():
result = await shorts.scrape(
"https://www.youtube.com/shorts/VIDEO_ID",
cache_dir="./downloads",
)
print(result.caption)
print(result.media_path(result.video_url))
asyncio.run(main())Set VPN_ENABLED=false before importing a scraper when running outside
Gluetun.
VPN_ENABLED=false python example.py- Use
from pinchana_scraper.shorts import scrapeto import the function directly. scrape()returns metadata and downloads media into the cache. Pass a returned media URL toresult.media_path()to find the local file, including carousel and quote attachments.- Catch
pinchana_core.ScrapeErrorfor scraper failures. It exposesstatus_codeanddetail. - Use one event loop for concurrent calls to a scraper. Check each module guide for platform credentials and local tool requirements.
| Operation | Available in |
|---|---|
scrape(url, *, cache_dir=None) |
All scrapers |
inspect(url) for metadata |
Bluesky, Coub, Threads, X / Twitter |
playlist(url) for ordered track URLs |
Deezer, Spotify |
scrape_playlist_item(url) for one YouTube video |
Shorts |
A single FastAPI process calls the bundled scrapers directly. The gateway
serves the API and cached media on port 8080 by default.
Clone the repository for the Compose files, then copy the sample configuration
and replace the placeholder in PINCHANA_API_KEYS. Give each machine client its
own named key so you can revoke it independently. Configuration example
git clone https://github.com/Pinchana/pinchana-api.git
cd pinchana-api
cp .env.example .env
chmod 600 .envPINCHANA_API_KEYS={"automation":"REPLACE_WITH_LONG_RANDOM_MACHINE_KEY"}Build the gateway from the checkout. This Compose file runs the gateway without a VPN.
docker compose --env-file .env -f docker-compose.dev.yml up --detach --buildConfigure the VPN in .env. For NordVPN OpenVPN, use the service username and
password from Nord Account's Manual setup page. Providers that issue manual
WireGuard keys can use VPN_TYPE=wireguard and WIREGUARD_PRIVATE_KEY.
VPN_SERVICE_PROVIDER=nordvpn
VPN_TYPE=openvpn
OPENVPN_PROTOCOL=tcp
OPENVPN_USER=REPLACE_WITH_NORDVPN_SERVICE_USERNAME
OPENVPN_PASSWORD=REPLACE_WITH_NORDVPN_SERVICE_PASSWORDUse the rolling updater to pin the production images by digest, then start the stack. Gluetun publishes the gateway listener and provides VPN egress.
python scripts/update_rolling.py --env-file .env
docker compose --env-file .env config --quiet
docker compose --env-file .env up --detachUse the same updater for upgrades. Recreate Gluetun through Compose when its digest changes so it reloads VPN credentials. Docker operations guide
curl --fail-with-body --silent --show-error http://localhost:8080/healthSend the target URL to POST /v1/scrape with your machine key.
curl --fail-with-body --silent --show-error \
http://localhost:8080/v1/scrape \
--header 'Content-Type: application/json' \
--header 'X-API-Key: REPLACE_WITH_MACHINE_KEY' \
--data '{"url":"https://www.youtube.com/shorts/VIDEO_ID"}'The response contains data and meta. Read downloads from the ordered
data.media list. Images and videos include dimensions when the gateway can
probe the cached file. V1 errors include an error object with a stable
code and message.
| Endpoint | Purpose |
|---|---|
POST /v1/scrape |
Download media and return normalized metadata |
POST /v1/inspect |
Inspect supported posts and quote metadata without downloading media |
GET /media/… |
Fetch a cached file with the machine key |
POST /v1/bot/ytgroups |
Prepare a full YouTube video for a Telegram upload |
POST /scrape |
Return the legacy flat response |
Machine routes use X-API-Key. The OpenAPI reference is available at
/docs on the running gateway. Telegram cache behavior
| Client | Authentication | Scrape endpoint |
|---|---|---|
| Browser | POST /web/verify exchanges a Turnstile token for a bearer session |
POST /v1/web/scrape |
| Mobile | Use scoped installation tokens. Set MOBILE_AUTH_REQUIRED=true to require them for ordinary scrapes. |
POST /v1/mobile/scrape |
Browser and mobile sessions use /web/media/… and /mobile/media/…,
respectively. Check sessions with GET /web/session or GET /v1/mobile/session.
Configure Turnstile with TURNSTILE_SECRET_KEY,
TURNSTILE_EXPECTED_HOSTNAME, TURNSTILE_EXPECTED_ACTION=turnstile-spin-v1,
and TURNSTILE_SESSION_SECRET. The shipped mobile configuration uses
MOBILE_AUTH_MODE=guest. Instance certificates · Mobile installation authentication
The optional DLP profile handles full YouTube video downloads in isolated
workers. Mobile DLP always requires an authenticated installation. Keep
DLP_ENABLED=false until the production preflight and canary pass.
DLP rollout guide
| Cookie use | Compose setting | Default host location |
|---|---|---|
| Shorts and YouTube group uploads | SHORTS_COOKIES_DIR |
./secrets/yt-cookies/ |
| DLP fallback for full videos | DLP_HOST_COOKIES_DIR |
./secrets/dlp-cookies/youtube.txt |
Compose mounts both directories read-only. Use a Netscape cookie file from an account that can play the requested video. DLP uses client-submitted cookies first when present. Shorts cookies · DLP host cookies
| Endpoint | Purpose |
|---|---|
GET /health |
Check gateway and scraper health |
GET /admin/modules |
List loaded scrapers and URL patterns |
GET /admin/vpn/status |
Check the VPN |
POST /admin/vpn/rotate |
Request a VPN reconnect |
| Scraper | Install individually | Individual import | Bundle import | Typical URLs |
|---|---|---|---|---|
| Apple Music | pip install pinchana-apple-music |
pinchana_apple_music |
apple_music |
music.apple.com, individual tracks |
| Bluesky | pip install pinchana-bluesky |
pinchana_bluesky |
bluesky |
bsky.app/profile/<handle-or-did>/post/<id> |
| Coub | pip install pinchana-coub |
pinchana_coub |
coub |
coub.com/view/…, coub.com/embed/… |
| Deezer | pip install pinchana-deezer |
pinchana_deezer |
deezer |
deezer.com and Deezer share links |
pip install pinchana-inst |
pinchana_inst |
instagram |
instagram.com, instagr.am |
|
| SoundCloud | pip install pinchana-soundcloud |
pinchana_soundcloud |
soundcloud |
soundcloud.com, on.soundcloud.com |
| Spotify | pip install pinchana-spotify |
pinchana_spotify |
spotify |
open.spotify.com |
| Threads | pip install pinchana-threads |
pinchana_threads |
threads |
threads.net, threads.com |
| TikTok | pip install pinchana-tiktok |
pinchana_tiktok |
tiktok |
tiktok.com, vm.tiktok.com, vt.tiktok.com, tt.site |
| X / Twitter | pip install pinchana-twitter |
pinchana_twitter |
twitter |
x.com, twitter.com, share links via the gateway |
| YouTube groups | pip install pinchana-ytgroups |
pinchana_ytgroups |
ytgroups |
youtube.com/watch, youtu.be via the Telegram gateway endpoint |
| YouTube Music | pip install pinchana-ytmusic |
pinchana_ytmusic |
ytmusic |
music.youtube.com |
| YouTube Shorts | pip install pinchana-shorts |
pinchana_shorts |
shorts |
youtube.com/shorts/… |
| Path | Responsibility |
|---|---|
pinchana-core/ |
Shared models, caching, music helpers, and Gluetun control |
pinchana-scraper/ |
Python bundle and scraper imports |
pinchana-server/ |
FastAPI gateway, authentication, and HTTP response handling |
scrapers/ |
Platform scraper packages |
pinchana-dlp/ |
Optional private download services and workers |
docs/ |
Deployment, client auth, and release guides |
Run the gateway directly or run its test suite from the repository root.
VPN_ENABLED=false uv run --project pinchana-server --locked \
uvicorn pinchana_server.main:app --reload
uv run --project pinchana-server --locked pytest -q pinchana-server/testsTo add a scraper under scrapers/, follow the Bluesky package for plugin
registration. Add it to the gateway's module list and Python dependencies, then expose
its Python functions through the bundle. Refresh both lockfiles and test both entry
points. Bluesky package · Gateway module list · Bundle sources
Update a checkout that still uses Git submodules
Back up any module edits or local files you need before deinitializing the old submodules.
git submodule deinit --all
git -c submodule.recurse=false pull --ff-onlyFor a stack that still has a container per scraper, follow the first-upgrade instructions in the Docker guide.
VERSION uses YY.MM.ITERATION. The release script keeps Python package
versions and lockfiles in sync. Publishing a stable GitHub Release uploads
all Python packages to PyPI. Pushing its tag builds the gateway and DLP
images on GHCR.
| Channel | GHCR tags |
|---|---|
| Main branch snapshot | latest |
| Tagged release | An exact version such as 26.11.14, monthly 26.11, and stable |
Images live under ghcr.io/pinchana/pinchana-api/. See the release guide for
building, publishing, and verifying a tagged release.
Release guide
Pinchana is released under the MIT License. License text