$ show anxdpanic/plugin.video.youtube
This repository contains `plugin.video.youtube`, a Kodi Media Center add-on that provides full YouTube browsing, search, subscription management, and video playback with adaptive streaming (MPEG-DASH, HLS), subtitles, and multi-user OAuth authentication. Architecturally, it is a Kodi plugin with a background service, an embedded HTTP server for streaming proxy and API configuration, and a layered framework (Kodion) offering abstract base classes for context, items, settings, caching, and network requests. The codebase is substantial (262 files) and demonstrates solid engineering with reusable patterns such as a generic SQLite key-value store (`Storage`), a robust HTTP client with retry/caching hooks, centralized logging with sensitive data redaction, and an item model hierarchy convertible to Kodi ListItems. However, several components depend on reverse-engineered YouTube InnerTube endpoints and JavaScript signature extraction (`cipher.py`, `ratebypass.py`), which are fragile and known to be partially broken (signatureCipher and nsig handling are disabled). The add-on also maintains Python 2/3 compatibility shims and version-dependent Kodi workarounds. Localization is extensive but many translations are incomplete. Overall, the add-on is actively maintained and functionally comprehensive, but its heavy reliance on brittle reverse-engineering and the accumulation of legacy compatibility code introduce moderate technical drift.
The LLM identified 4 files worth highlighting for reuse:
Generic SQLite-backed key-value store with deferred writes, in-memory cache, automatic pruning by count or file size, and WAL mode. Designed for multiple cache/history stores (FunctionCache, RequestCache, etc.). Highly reusable as a standalone persistent dictionary for any Python/Kodi add-on requiring lightweight caching.
Central HTTP client for YouTube API requests with configurable error hooks, ETag/If-Modified-Since caching, retry logic, proxy support, and SSL context. Includes `json_traverse()` utility for extracting data from nested InnerTube JSON using tuple/slice paths, which can be reused in any project dealing with unstable nested JSON responses.
Logging module that integrates with Kodi's log system while providing custom conversion flags (`!r`, `!p`, `!u`) to automatically redact sensitive parameters (tokens, keys, IPs) and pretty-print complex objects. The redaction logic is independently extractable for any Python project requiring security-conscious logging.
Base class for a hierarchical item model (`BaseItem` → `DirectoryItem`, `MediaItem`, `VideoItem`, `AudioItem`, etc.) with JSON serialization, property-based validation, and thumbnail/metadata handling. This pattern is cleanly isolated and can be reused in any media-browsing application requiring a consistent item abstraction.