$ show jurialmunkey/plugin.video.themoviedb.helper
This is a Kodi video addon (plugin.video.themoviedb.helper) that provides rich metadata enrichment, browsing, discovery, player resolution, and synchronization for movies and TV shows. It integrates with multiple external APIs including TMDb, Trakt, TVDb, MDbList, FanartTV, OMDb, and Gemini AI. The architecture follows the Kodi addon pattern with three entry points: a plugin for directory listings, a background service for monitoring and scrobbling, and a script for one-off actions. The codebase is heavily modular with over 200 Python files organized into API wrappers, caching layers, database factories, sync engines, player configuration, and UI dialogs. It features extensive SQLite caching with thread-safe mutex locks, a custom import hook for API key permissions, and a flexible player resolution system based on JSON configuration files. While primarily an application, it includes significant data engineering patterns for caching, incremental syncing, and data transformation.
The LLM identified 5 files worth highlighting for reuse:
Provides SafeHThread, ParallelThread, and TimerFunc classes for thread-safe concurrent execution. Implements a thread pool with mutex locks and join patterns. Can be extracted for any Python project needing safe multithreading without external dependencies beyond standard library.
Implements a thread-safe cache with TTL expiry, mutex locking, and optional disk persistence. Uses a dictionary-based store with cleanup routines. Reusable as a standalone caching module for API responses or computed data in any Python application.
Implements a custom Python import hook (sys.metapath) that restricts which API key modules can be imported based on user settings. Prevents unauthorized access to third-party API credentials. Demonstrates a non-obvious pattern for runtime permission enforcement in plugin architectures.
Provides TokenHandler class for encrypting and decrypting API tokens using a key derived from a user-provided passphrase. Uses AES encryption with PBKDF2 key derivation. Can be extracted for any application needing secure local storage of sensitive tokens.
Implements DatabaseCore and DatabaseMethod classes that provide generic SQLite CRUD operations with parameterized statement builders (insert, update, select, delete). Supports context managers, mutex locking, and schema versioning. Reusable as a lightweight database layer for any SQLite-backed project.