# 25175/tvyuan architecture

> Architecture diagram of the GitHub repository 25175/tvyuan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/25175/tvyuan
- Repository: https://github.com/25175/tvyuan

## Overview

#### Purpose and published artifacts
This repository is an automated TVBox media-source aggregator. It fetches upstream source definitions, validates and ranks sources, then commits client-consumable JSON configurations:
- Compact, tested collector sources: `tvbox.json`
- Merged full configuration with spider/JAR support: `tvbox_full.json`
- Separate upstream repositories for multi-repository-capable clients: `tvbox_multi.json`

#### Entrypoints and automation
The operational entrypoint is `update.py`, executed on an hourly GitHub Actions schedule. The workflow in `.github/workflows/update.yml` is the production orchestrator: it runs the updater and publishes refreshed generated JSON back to the repository. Static inputs and generated outputs are versioned together.

#### Source ingestion boundary
`sources.txt` is the upstream-source registry consumed by the update process. Upstream data originates from the external TVBox source service described in the README. `update.py` is responsible for pulling source configurations and treating remote source data as untrusted: unavailable entries are removed and can reappear in later runs once reachable.

Grounding paths:
- `sources.txt`
- `update.py`

#### Validation and ranking pipeline
`update.py` implements the central quality pipeline: retrieve candidate video content, fetch and parse m3u8 playlists, download TS segments, and calculate sustained playback speed. Collector sources are ordered by measured playback performance; crawler-style sources are ordered by latency. Sony and 360 sources are explicitly pinned ahead of normal ranking.

This separates client-facing source ordering from raw upstream order and ensures the compact output retains only the fastest fixed subset of collector sources.

Grounding paths:
- `update.py`
- `tvbox.json`

#### Configuration assembly variants
The updater projects one source pool into three compatibility-oriented output contracts:
- `tvbox.json`: minimal collector-only configuration, fixed to the fastest ten and independent of a JAR.
- `tvbox_full.json`: aggregate configuration retaining all applicable sites, with collectors first and crawler sites later, including spider/JAR references.
- `tvbox_multi.json`: preserves individual upstream repositories and their associated JAR/site sets for clients that support switching repositories.

Grounding paths:
- `tvbox.json`
- `tvbox_full.json`
- `tvbox_multi.json`

#### Runtime, network, and delivery infrastructure
Python is the execution runtime implied by `update.py`; GitHub Actions supplies scheduled compute and repository write/publish automation. The update environment uses a Cloudflare Tunnel plus a local/domestic-IP proxy for tests against collection sites that may block GitHub-hosted IP ranges. Final JSON is delivered through repository raw URLs and a custom direct domain, while Gitee is an additional mirror/distribution channel.

Grounding paths:
- `.github/workflows/update.yml`
- `update.py`
- `README.md`

#### Primary control flow
Hourly schedule → workflow execution → load `sources.txt` → fetch upstream repository/source definitions → playback/latency checks through proxy/tunnel → remove failed sources and rank viable ones → generate compact/full/multi JSON projections → commit updated `tvbox*.json` artifacts. Consumers never invoke repository code; TVBox-compatible clients fetch the published JSON artifacts directly.

Main entry points: [`update.py`](https://github.com/25175/tvyuan/blob/master/update.py) (Candidate sources), [`.github/workflows/update.yml`](https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml) (Repository publishing), [`tvbox.json`](https://github.com/25175/tvyuan/blob/master/tvbox.json) (Compact config), [`tvbox_full.json`](https://github.com/25175/tvyuan/blob/master/tvbox_full.json) (Full config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_automation["Automation"]
  node_schedule(("Hourly schedule<br/>GitHub Actions trigger<br/>[update.yml]"))
  node_workflow["Update workflow<br/>GitHub Actions workflow<br/>[update.yml]"]
  node_python["Python runtime<br/>[update.py]"]
  node_repository[("Repository publishing<br/>versioned delivery<br/>[update.yml]")]
end

subgraph group_pipeline["Update pipeline"]
  node_registry["Upstream registry<br/>source list<br/>[sources.txt]"]
  node_updater["Updater<br/>aggregation job<br/>[update.py]"]
  node_proxy{{"Tunnel and domestic proxy<br/>network test route<br/>[update.py]"}}
  node_candidates["Candidate sources<br/>source pool<br/>[update.py]"]
  node_playback["Playback checks<br/>validation stage<br/>[update.py]"]
  node_ranking["Ranking and filtering<br/>quality stage<br/>[update.py]"]
end

subgraph group_artifacts["Published artifacts"]
  node_compact["Compact config<br/>generated JSON<br/>[tvbox.json]"]
  node_full["Full config<br/>generated JSON<br/>[tvbox_full.json]"]
  node_multi["Multi-repository config<br/>generated JSON<br/>[tvbox_multi.json]"]
end

node_upstream{{"TVBox source service<br/>external upstream"}}
node_clients(("TVBox-compatible clients<br/>consumer"))
node_distribution{{"Raw, custom-domain, and Gitee delivery<br/>distribution channels<br/>[README.md]"}}

node_schedule -->|"triggers"| node_workflow
node_workflow -->|"runs"| node_python
node_python -->|"executes"| node_updater
node_registry -->|"source URLs"| node_updater
node_upstream -->|"source definitions"| node_candidates
node_updater -->|"fetches"| node_candidates
node_proxy -->|"routes checks"| node_playback
node_candidates -->|"validates collectors"| node_playback
node_playback -->|"speed results"| node_ranking
node_candidates -->|"crawler latency"| node_ranking
node_ranking -->|"top 10 collectors"| node_compact
node_ranking -->|"merged sites and JARs"| node_full
node_candidates -->|"preserved upstream sets"| node_multi
node_compact -->|"committed"| node_repository
node_full -->|"committed"| node_repository
node_multi -->|"committed"| node_repository
node_repository -->|"publishes"| node_distribution
node_distribution -->|"serves configs"| node_clients

click node_schedule "https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml"
click node_workflow "https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml"
click node_python "https://github.com/25175/tvyuan/blob/master/update.py"
click node_registry "https://github.com/25175/tvyuan/blob/master/sources.txt"
click node_updater "https://github.com/25175/tvyuan/blob/master/update.py"
click node_proxy "https://github.com/25175/tvyuan/blob/master/update.py"
click node_candidates "https://github.com/25175/tvyuan/blob/master/update.py"
click node_playback "https://github.com/25175/tvyuan/blob/master/update.py"
click node_ranking "https://github.com/25175/tvyuan/blob/master/update.py"
click node_compact "https://github.com/25175/tvyuan/blob/master/tvbox.json"
click node_full "https://github.com/25175/tvyuan/blob/master/tvbox_full.json"
click node_multi "https://github.com/25175/tvyuan/blob/master/tvbox_multi.json"
click node_repository "https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml"
click node_distribution "https://github.com/25175/tvyuan/blob/master/README.md"

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_schedule,node_workflow,node_python,node_repository toneBlue
class node_registry,node_updater,node_proxy,node_candidates,node_playback,node_ranking toneAmber
class node_compact,node_full,node_multi toneMint
class node_upstream,node_clients,node_distribution toneNeutral
```

## Components

### Automation

- [Hourly schedule](https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml): GitHub Actions trigger · `.github/workflows/update.yml`
- [Update workflow](https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml): GitHub Actions workflow · Runs and publishes the updater. · `.github/workflows/update.yml`
- [Python runtime](https://github.com/25175/tvyuan/blob/master/update.py): runtime · `update.py`
- [Repository publishing](https://github.com/25175/tvyuan/blob/master/.github/workflows/update.yml): versioned delivery · Commits generated artifacts with their static inputs. · `.github/workflows/update.yml`

### Update pipeline

- [Upstream registry](https://github.com/25175/tvyuan/blob/master/sources.txt): source list · Lists upstream source repositories. · `sources.txt`
- [Updater](https://github.com/25175/tvyuan/blob/master/update.py): aggregation job · Fetches, validates, ranks, and assembles source configurations. · `update.py`
- [Tunnel and domestic proxy](https://github.com/25175/tvyuan/blob/master/update.py): network test route · Routes checks around collection-site IP blocking. · `update.py`
- [Candidate sources](https://github.com/25175/tvyuan/blob/master/update.py): source pool · Remote entries treated as untrusted until validated. · `update.py`
- [Playback checks](https://github.com/25175/tvyuan/blob/master/update.py): validation stage · Fetches content, parses m3u8, downloads TS segments, and measures sustained speed. · `update.py`
- [Ranking and filtering](https://github.com/25175/tvyuan/blob/master/update.py): quality stage · Removes failures; pins Sony and 360; ranks collectors by speed and crawlers by latency. · `update.py`

### Published artifacts

- [Compact config](https://github.com/25175/tvyuan/blob/master/tvbox.json): generated JSON · Fastest ten collector sources without a JAR. · `tvbox.json`
- [Full config](https://github.com/25175/tvyuan/blob/master/tvbox_full.json): generated JSON · All applicable sites, with collectors first and spider/JAR support. · `tvbox_full.json`
- [Multi-repository config](https://github.com/25175/tvyuan/blob/master/tvbox_multi.json): generated JSON · Preserves upstream repositories and their JAR/site sets. · `tvbox_multi.json`

### Other components

- **TVBox source service**: external upstream · Provides remote source configurations.
- **TVBox-compatible clients**: consumer · Fetch published JSON directly rather than running repository code.
- [Raw, custom-domain, and Gitee delivery](https://github.com/25175/tvyuan/blob/master/README.md): distribution channels · `README.md`

## Connections

- Hourly schedule → Update workflow: triggers
- Update workflow → Python runtime: runs
- Python runtime → Updater: executes
- Upstream registry → Updater: source URLs
- TVBox source service → Candidate sources: source definitions
- Updater → Candidate sources: fetches
- Tunnel and domestic proxy → Playback checks: routes checks
- Candidate sources → Playback checks: validates collectors
- Playback checks → Ranking and filtering: speed results
- Candidate sources → Ranking and filtering: crawler latency
- Ranking and filtering → Compact config: top 10 collectors
- Ranking and filtering → Full config: merged sites and JARs
- Candidate sources → Multi-repository config: preserved upstream sets
- Compact config → Repository publishing: committed
- Full config → Repository publishing: committed
- Multi-repository config → Repository publishing: committed
- Repository publishing → Raw, custom-domain, and Gitee delivery: publishes
- Raw, custom-domain, and Gitee delivery → TVBox-compatible clients: serves configs
