Disclaimer: This documentation is provided for convenience and may contain errors. Always verify information against the official Kodi and provider documentation. Report issues.
Fastmail
Home / Files / sky.py

resources/lib/sky.py — Sky News live resolver

Path /resources/lib/sky.py Lines 64 Type playback resolver (DASH + Widevine optional) ← called by default.py:_resolve_channel (only for the Sky News channel) → calls news.sky.com HTML scrape + Brightcove Playback API, setup_dash_item

Role

Resolves the single live Sky News stream. No catalog (it's a single-channel entry in CUTV_UK_CHANNELS). Sky News uses Brightcove as its video backend, so the resolver sequence is the Brightcove-standard: scrape account/player/video-id from the page, extract a policy key from Brightcove's player JS, then call the Brightcove Playback API with that policy key to receive the list of manifests.

Constants

URL_LIVE = "https://news.sky.com/watch-live" · URL_POLICY_KEY = "https://players.brightcove.net//_default/index.min.js" · URL_PLAYBACK = "https://edge.api.brightcove.com/playback/v1/accounts//videos/" · lines 7-9

The three Brightcove endpoint roots.

GENERIC_HEADERS = {"User-Agent": ""} · line 11

Empty UA placeholder — filled at runtime with get_ua().

Resolver

resolve(listitem) · line 14

Note the signature: no item_id argument — there's only one Sky News stream. Steps:

  1. Fetch watch-live and regex-match the
    element. This is the container for all the Brightcove data-attributes.
  2. From the div tag, extract data-account-id, data-player-id, and data-video-id. Raises "Sky: missing Brightcove data attributes" if any are absent.
  3. Treat the video id as a Brightcove reference id by prefixing "ref:" — Sky's video is referenced by a stable string like "skynews-live-uk", not by Brightcove's numeric id.
  4. Fetch the player JS bundle from Brightcove and regex-extract the policyKey:"…" — this is the JWT-style token used by the Playback API auth. Raises "Sky: policy key not found" if missing.
  5. Build the Playback API request with two non-obvious headers:
  6. a. Accept: application/json;pk= — the policy key goes in the Accept header, not in Authorization. This is Brightcove's idiom.
  7. b. X-Forwarded-For: 2.97.0.0 — a UK IP spoofed into the request, because Brightcove geofences by requesting IP and our scraping host may not be in the UK (OSMC running outside UK in test setups). 2.97.0.0 is a Sky-class A block, so geofencing sees it as UK.
  8. Parse the Playback response — iterate sources, prefer DASH with Widevine (key_systems"["com.widevine.alpha"]["license_url"]), fall back to clear DASH or HLS.
  9. Hand to setup_dash_item with the license URL only if Widevine path was used.
X-Forwarded-For spoofing is brittle and per-policy

Brightcove's policy key is bound to a Sky-defined policy that may or may not trust the X-Forwarded-For header. If Sky rotate to a policy that ignores forwarded IPs (most modern CDN policies do), this resolver would start returning AU/US Clear manifest URLs that don't play on a UK Kodi box. The RBI fallback doesn't exist for this provider — the addon doesn't include a UK-IP egress path. If you start seeing "this content is not available in your region" failures for Sky News, check the XFF header behavior first.