Overview
Theremote_config module integrates with Firebase Remote Config to dynamically fetch API endpoint URLs. This allows the Cricfy plugin to update API endpoints without requiring plugin updates.
This implementation is based on the Firebase Remote Config REST API and mimics an Android app client to retrieve configuration values.Credits: Adapted from CNCVerse Cloud Stream Extension
Functions
fetch_remote_config()
Fetches Firebase Remote Config and returns the configuration entries.Dictionary of configuration entries (key-value pairs), or
None if fetch failsCommon entries:"cric_api1": Primary API endpoint URL"cric_api2": Secondary API endpoint URL
| Header | Value |
|---|---|
Content-Type | application/json |
Accept | application/json |
X-Android-Package | {CRICFY_PACKAGE_NAME} |
X-Goog-Api-Key | {CRICFY_FIREBASE_API_KEY} |
X-Google-GFE-Can-Retry | yes |
Firebase credentials are loaded from
resources/cricfy_properties.json:cricfy_package_name: Android package identifiercricfy_firebase_api_key: Firebase Web API keycricfy_firebase_app_id: Firebase App ID (format:1:PROJECT_NUMBER:...)
get_provider_api_url()
Gets the provider API URL from Firebase Remote Config with retry logic.Provider API base URL, or
None if all retry attempts fail- Retries up to 3 times if fetch fails
- Prioritizes
"cric_api2"over"cric_api1" - Returns the first available API URL
- Returns
Noneif no API URLs are available after all retries
get_api_urls()
Gets all available API URLs from Firebase Remote Config.Tuple containing
(api1, api2) where each value is a string URL or NoneReturns None if the remote config fetch fails entirely- Load balancing between endpoints
- Fallback logic if one endpoint fails
- Health monitoring of multiple endpoints
Internal Functions
_get_random_instance_id()
Generates a random UUID without dashes for use as a fake app instance ID.32-character hexadecimal string (UUID without hyphens)
Configuration File
cricfy_properties.json
The module reads Firebase configuration from{ADDON_PATH}/resources/cricfy_properties.json:
Android package identifier (reverse domain notation)
Firebase Web API Key (starts with
AIzaSy)Firebase App ID in format
1:PROJECT_NUMBER:android:APP_IDConstants
| Constant | Source | Description |
|---|---|---|
CRICFY_PACKAGE_NAME | cricfy_properties.json | Android package name |
CRICFY_FIREBASE_API_KEY | cricfy_properties.json | Firebase API key |
CRICFY_FIREBASE_APP_ID | cricfy_properties.json | Firebase app identifier |
PROJECT_NUMBER | Extracted from app ID | Firebase project number |
"1:123456789:android:abc123", extracts "123456789"
Response Format
Successful Response
Firebase Remote Config returns JSON in this format:"entries" dictionary.
Dependencies
requests- HTTP client for API requestsuuid- Random instance ID generationjson- JSON parsinglib.config.ADDON_PATH- Plugin installation pathlib.logger- Error logging
