Implement ViewIt Plugin System Documentation and Update Project Notes
- Added comprehensive documentation for the ViewIt Plugin System, detailing the plugin loading process, required methods, optional features, and community extension workflow. - Updated project notes to reflect the current structure, build process, search logic, and known issues. - Introduced new build scripts for installing the add-on and creating ZIP packages. - Added test scripts for TMDB API integration, including argument parsing and logging functionality. - Enhanced existing plugins with improved search logic and error handling.
This commit is contained in:
34
dist/plugin.video.viewit/http_session_pool.py
vendored
Normal file
34
dist/plugin.video.viewit/http_session_pool.py
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Shared requests.Session pooling for plugins.
|
||||
|
||||
Goal: reuse TCP connections/cookies across multiple HTTP calls within a Kodi session.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
try: # pragma: no cover - optional dependency
|
||||
import requests
|
||||
except Exception: # pragma: no cover
|
||||
requests = None
|
||||
|
||||
_SESSIONS: Dict[str, Any] = {}
|
||||
|
||||
|
||||
def get_requests_session(key: str, *, headers: Optional[dict[str, str]] = None):
|
||||
"""Return a cached `requests.Session()` for the given key."""
|
||||
if requests is None:
|
||||
raise RuntimeError("requests ist nicht verfuegbar.")
|
||||
key = (key or "").strip() or "default"
|
||||
session = _SESSIONS.get(key)
|
||||
if session is None:
|
||||
session = requests.Session()
|
||||
_SESSIONS[key] = session
|
||||
if headers:
|
||||
try:
|
||||
session.headers.update({str(k): str(v) for k, v in headers.items() if k and v})
|
||||
except Exception:
|
||||
pass
|
||||
return session
|
||||
|
||||
Reference in New Issue
Block a user