How tellytv/go.xtream-codes works
Project Type and Purpose
• This is a Go client library (SDK) for interacting with Xtream-Codes IPTV servers. It provides a set of high-level functions to authenticate, fetch live/VOD categories and streams, and optionally invoke ffmpeg for stream processing.
File Structure Analysis
• Top-level Go modules:
• xtream-codes.go – core client interface & request orchestration
• structs.go / flex_types.go – domain models and flexible JSON type handling
• base64.go – utility for encoding/decoding (used in authentication)
• ffmpeg.go – wrapper around ffmpeg CLI for stream conversion or probing
• Testing:
• xtream-codes_test.go – unit tests for client functions
• testData/… – JSON fixtures for multiple providers (eternal, hellraiser, iris, tnt)
• Tooling/config:
• .circleci/config.yml – CI pipeline setup
• .gometalinter.json – linting rules
Insights from README
• Confirms the library’s sole role is to provide an API to Xtream-Codes servers.
• Minimal external dependencies: Go stdlib, ffmpeg (optional), no UI/DB.
a. Main Components
1. Client Application (your downstream service or microservice)
2. go.xtream-codes Library
– HTTP Client Module
– Authentication Module (base64 utility)
– Models / JSON Parser (structs.go + flex_types.go)
– ffmpeg Integration (ffmpeg.go)
3. External Services
– Xtream-Codes HTTP API Servers
– ffmpeg CLI binary
4. Dev/CI Environment
– Test Runner (uses testData fixtures)
– CircleCI pipeline
b. Relationships & Data Flows
1. The Client App imports go.xtream-codes and calls Authenticate().
2. Library’s Auth Module encodes credentials (base64.go) → HTTP Client issues POST to Xtream API.
3. HTTP Client receives JSON → Models/JSON Parser maps to Go structs.
4. Client App calls GetLiveStreams(), GetSeries(), etc.
5. Library may invoke ffmpeg CLI (ffmpeg.go) for stream manipulation.
6. CI Pipeline checks code quality → runs unit tests against testData fixtures.
c. Architectural Patterns & Principles
• Modular separation:
• Utilities (base64, flex types)
• Core client logic (xtream-codes.go)
• Integration points (ffmpeg wrapper)
• Single responsibility: each .go file/module has a distinct concern.
• Test-driven data validation: fixtures under testData drive struct accuracy.
d. Key Technologies & Frameworks
• Language: Go (modules via go.mod)
• HTTP/JSON: net/http, encoding/json
• External: ffmpeg CLI
• CI/Linters: CircleCI, gometalinter