Overview
Theproviders module handles fetching and caching provider lists and channels from the Cricfy service. It manages encrypted data retrieval, decryption, and intelligent caching to minimize network requests.
Functions
get_providers()
Fetches and decrypts the list of providers from Cricfy. Uses caching to avoid repeated network calls.List of provider dictionaries, each containing:
title(str): Provider nameimage(str): Provider logo URLcatLink(str): M3U playlist URL for the provider
[] if fetch fails or no providers available.- Checks cache first using the key
"cricfy_providers" - On cache miss, fetches from
{provider_api_url}/cats.txt - Decrypts the response using
decrypt_data() - Caches the decrypted JSON data indefinitely
- Returns empty list on any error
get_channels()
Fetches channels for a specific provider by parsing its M3U playlist.The M3U playlist URL for the provider (typically from
catLink field)List of PlaylistItem objects representing available channels. Each PlaylistItem contains channel metadata, URL, and streaming configuration.
- Cache key:
"channels_{sha256_hash(provider_url)}" - Cache TTL: 3600 seconds (1 hour)
- Cached data includes fetch timestamp for TTL validation
- Cache stores serialized PlaylistItem dictionaries
Internal Functions
_hash_key()
Internal helper to generate SHA-256 hashes for cache keys.String to hash (typically a URL)
Hexadecimal SHA-256 hash of the input string
Constants
| Constant | Value | Description |
|---|---|---|
PROVIDERS_CACHE_KEY | "cricfy_providers" | Cache key for provider list |
CHANNEL_CACHE_TTL | 3600 | Channel cache lifetime in seconds (1 hour) |
Dependencies
This module depends on:lib.config.cache- Caching functionalitylib.logger- Logging functionslib.crypto_utils- Decryption utilitieslib.req- HTTP request handlinglib.m3u_parser- M3U playlist parsinglib.remote_config- Remote configuration fetching
