# grqz/yt-dlp-getpot-jsi architecture

> Architecture diagram of the GitHub repository grqz/yt-dlp-getpot-jsi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grqz/yt-dlp-getpot-jsi
- Repository: https://github.com/grqz/yt-dlp-getpot-jsi

## Overview

This archived yt-dlp plugin generates YouTube PoTokens by extracting challenge data from a video request, running a bundled JavaScript interpreter in PhantomJS, and returning the minted token to yt-dlp. Its Python HTTP server supplies challenge and interpreter data and generates integrity-token responses; the JavaScript client uses those responses to snapshot the VM and mint tokens. The README describes the provider and PhantomJS requirements. Some JavaScript is excerpted only partially, so only visible endpoint relationships are shown.

Main entry points: [`py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py`](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py) (POT Orchestration), [`py/yt_dlp_plugins/getpot_phantomjs/server.py`](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/server.py) (Local HTTP Server), [`py/yt_dlp_plugins/extractor/ytpot_jsi.py`](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/extractor/ytpot_jsi.py) (PoToken Provider), [`py/yt_dlp_plugins/getpot_phantomjs/script.py`](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/script.py) (Script Assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provider["yt-dlp Provider"]
  node_provider["PoToken Provider<br/>[ytpot_jsi.py]"]
end

subgraph group_runtime["Python Runtime"]
  node_fetch["POT Orchestration<br/>[fetch_pot.py]"]
  node_server["Local HTTP Server<br/>[server.py]"]
  node_script["Script Assembly<br/>[script.py]"]
  node_phantom["PhantomJS Runner<br/>[phantom_jsi.py]"]
end

subgraph group_javascript["JavaScript Token Engine"]
  node_bundled["Bundled JS"]
  node_wrapper["Phantom Page Wrapper<br/>[wrapper.cjs]"]
  node_engine["Challenge and POT Logic<br/>[pot_http.es5.cjs]"]
end

subgraph group_integrity["Integrity Service"]
  node_bg["Challenge and IT<br/>[utils.py]"]
end

node_ydlp(("yt-dlp"))
node_google["Google Waa API"]
node_phantomexec["PhantomJS"]

node_ydlp -->|"requests token"| node_provider
node_provider -->|"fetches POT"| node_fetch
node_fetch -->|"starts server"| node_server
node_fetch -->|"assembles script"| node_script
node_fetch -->|"executes script"| node_phantom
node_server -->|"fetches challenge"| node_bg
node_server -->|"generates integrity"| node_bg
node_bg -->|"calls Waa API"| node_google
node_script -->|"embeds JavaScript"| node_bundled
node_script -->|"wraps script"| node_wrapper
node_phantom -->|"runs script"| node_phantomexec
node_wrapper -->|"evaluates script"| node_engine
node_engine -->|"posts /genit"| node_server
node_provider -->|"returns token"| node_ydlp

click node_provider "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/extractor/ytpot_jsi.py"
click node_fetch "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py"
click node_server "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/server.py"
click node_bg "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/utils.py"
click node_script "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/script.py"
click node_phantom "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/phantom_jsi.py"
click node_wrapper "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/js/src/wrapper.cjs"
click node_engine "https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/js/src/pot_http.es5.cjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_provider toneBlue
class node_fetch,node_server,node_script,node_phantom toneAmber
class node_bundled,node_wrapper,node_engine,node_google toneMint
class node_bg toneRose
class node_ydlp,node_phantomexec toneIndigo
```

## Components

### yt-dlp Provider

- [PoToken Provider](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/extractor/ytpot_jsi.py): `py/yt_dlp_plugins/extractor/ytpot_jsi.py`

### Python Runtime

- [POT Orchestration](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py): `py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py`
- [Local HTTP Server](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/server.py): `py/yt_dlp_plugins/getpot_phantomjs/server.py`
- [Script Assembly](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/script.py): `py/yt_dlp_plugins/getpot_phantomjs/script.py`
- [PhantomJS Runner](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/phantom_jsi.py): `py/yt_dlp_plugins/getpot_phantomjs/phantom_jsi.py`

### JavaScript Token Engine

- **Bundled JS**
- [Phantom Page Wrapper](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/js/src/wrapper.cjs): `js/src/wrapper.cjs`
- [Challenge and POT Logic](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/js/src/pot_http.es5.cjs): `js/src/pot_http.es5.cjs`

### Integrity Service

- [Challenge and IT](https://github.com/grqz/yt-dlp-getpot-jsi/blob/master/py/yt_dlp_plugins/getpot_phantomjs/utils.py): `py/yt_dlp_plugins/getpot_phantomjs/utils.py`

### Other components

- **yt-dlp**
- **Google Waa API**
- **PhantomJS**

## Connections

- yt-dlp → PoToken Provider: requests token (evidence: `py/yt_dlp_plugins/extractor/ytpot_jsi.py`)
- PoToken Provider → POT Orchestration: fetches POT (evidence: `py/yt_dlp_plugins/extractor/ytpot_jsi.py`)
- POT Orchestration → Local HTTP Server: starts server (evidence: `py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py`)
- POT Orchestration → Script Assembly: assembles script (evidence: `py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py`)
- POT Orchestration → PhantomJS Runner: executes script (evidence: `py/yt_dlp_plugins/getpot_phantomjs/fetch_pot.py`)
- Local HTTP Server → Challenge and IT: fetches challenge (evidence: `py/yt_dlp_plugins/getpot_phantomjs/server.py`)
- Local HTTP Server → Challenge and IT: generates integrity (evidence: `py/yt_dlp_plugins/getpot_phantomjs/server.py`)
- Challenge and IT → Google Waa API: calls Waa API (evidence: `py/yt_dlp_plugins/getpot_phantomjs/utils.py`)
- Script Assembly → Bundled JS: embeds JavaScript (evidence: `py/yt_dlp_plugins/getpot_phantomjs/script.py`)
- Script Assembly → Phantom Page Wrapper: wraps script (evidence: `py/yt_dlp_plugins/getpot_phantomjs/script.py`)
- PhantomJS Runner → PhantomJS: runs script (evidence: `py/yt_dlp_plugins/getpot_phantomjs/phantom_jsi.py`)
- Phantom Page Wrapper → Challenge and POT Logic: evaluates script (evidence: `js/src/wrapper.cjs`)
- Challenge and POT Logic → Local HTTP Server: posts /genit (evidence: `js/src/pot_http.es5.cjs`)
- PoToken Provider → yt-dlp: returns token (evidence: `py/yt_dlp_plugins/extractor/ytpot_jsi.py`)
