goj · docs/architecture.md · chart 1
the goj codebook
one page URL in, one playable file out. goj reads the page through the site's TLS-fingerprint gate, pulls the media URL out of it, parses the HLS playlist, fetches and decrypts the segments in parallel, emits them in playlist order, and tees them into a concurrent ffmpeg for a lossless MP4. Two sibling modes crawl a listing into a list of video URLs (--list), or download every URL in a list file (--download-list).
world map — the whole pipeline
the chart from docs/architecture.md, drawn from the code. [Z] ACTUAL SIZE switches the file to the diagram's intrinsic 1677 × 4557 px size with scrollbars in both directions; zooming the browser stays sharp because the chart here is vector SVG, not a bitmap.
reading the chart
| Part | What it does |
|---|---|
main.go | Parses flags, picks the mode (single URL, --list, --download-list), wires everything, and owns the exit codes 0 / 1 / 2. |
internal/page | Reads the page over HTTPS presenting a browser's TLS ClientHello (four fingerprints tried in order, ALPN pinned to http/1.1) and extracts the media URL — or, for a listing, the video URLs and the next-page link. |
internal/listing | Walks a listing's pagination, dedupes the videos it finds, and reads/writes the one-URL-per-line list file. |
internal/hls | Pure playlist parsing: one AES-128 key with its explicit IV, and the ordered segments; also resolves relative key and segment URIs. |
internal/media | The heart: one worker goroutine per segment bounded by a semaphore, retries with backoff, AES-128-CBC decrypt with PKCS#7 strip, a bounded reorder window, and a single emitter that writes strictly in playlist order. |
internal/output | The sink: appends to the .ts and tees the same bytes into a concurrent ffmpeg -c copy, renaming .mp4.part to .mp4 only on success; keeps the .ts when ffmpeg is absent; aborts remove the partial files. |
internal/progress | The two live lines on stderr — a spinner for the page/list phase and a bar for the segments — drawn only when stderr is a console. |
| Network boxes | jable.tv sits behind a gate that decides on the TLS handshake; the media host speaks HTTP/1.1 only, which the media client pins deliberately. |