From 149248fe0a0929269dbfeafe5439750cf7e71680 Mon Sep 17 00:00:00 2001 From: pQu4k3r Date: Sun, 29 Nov 2026 17:30:23 +0000 Subject: [PATCH 1/3] Vavoo source: vavoo.to's channel index when the catalog API fails The user: "Vavoo/Kool only" has no channels - vavoo.to and kool.to answer the catalog with HTTP 500. Checked from here: Vavoo's catalog API (/mediahubmx-catalog.json) answers 500 "Internal error" on both sites to every token (VYPN, Vavoo, Lokke), every request, and with no token at all - it is down for everyone. vavoo.to's own channel index (/live2/index?countries=all&output=json) still answers: 10 000+ entries, 17 countries, a guide id each, no token; its play addresses (/live2/play3/.m3u8) redirect to a stream server, and played on the user's box (sf8008: 200, an HLS playlist). - load_catalog(): when no site gives the catalog, load_vavoo_index() - the id from the play address, fix_geil_name() on the name ("(1)/(6)/ (7)" -> ".b/.c/.s": sources group as Geil's), the logo fixed, tvg_id as epg_id, at least 100 channels. Its failure only logged: the status line keeps the API's error. - _resolve_vavoo_index(): the 302's Location asked once (a new one each request) and kept in the resolve cache, so /vavoo stays on one address for the viewing; no token for the player, a recording (resolve_own()) or prefetch(). - tests/test_vavoo_index.py (Python 2 and 3): fake site - the index's channels, sources grouped, resolve once and cached, /vavoo and a group through the proxy, recording and prefetch without a token, a 200 / 404 play address, the API first when it answers, an index that fails or is short. test_catalog_source: the index on its fake site. - Checked against the real vavoo.to from here: "READY 10468 channels (vavoo)", Portugal 201 rows, AXN /vavoo -> 302 to the stream server. - CLAUDE.md, README / readme. --- CLAUDE.md | 20 +- README.md | 8 + tests/run_tests.py | 3 +- tests/test_catalog_source.py | 2 + tests/test_vavoo_index.py | 252 ++++++++++++++++++ .../python/Plugins/Extensions/vavoo/readme.md | 8 + .../Plugins/Extensions/vavoo/vavoo_proxy.py | 148 +++++++++- 7 files changed, 435 insertions(+), 6 deletions(-) create mode 100644 tests/test_vavoo_index.py diff --git a/CLAUDE.md b/CLAUDE.md index f3643e25..78f165dd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -387,14 +387,30 @@ on `127.0.0.1:4323`. It: - `prefetch(channel_id)`: the player (`Playstream2._schedule_prefetch()`, 3 s after `zap_to()`, the next channel in the zap's direction - CH+ +1, CH- -1, the rest +1) has the address resolved ahead, into the - resolve cache. Geil only (Vavoo plays one stream per token: no - resolve on the shared one); a group's first source by + resolve cache. Geil and vavoo.to's channel index only (Vavoo's API + plays one stream per token: no resolve on the shared one); a group's + first source by `_ordered_group_members()` (read-only: no `_group_state`); no stream count; one at a time (`_prefetch_lock`). - Falls back from `vavoo.to` to `kool.to` on HTTP 451, and (`load_catalog()` over `_load_catalog_site()`) for the catalog on any first-page failure: an HTTP 5xx (asked once more first), no connection, a broken answer. +- When no site gives Vavoo's catalog API (`/mediahubmx-catalog.json` + answered HTTP 500 "Internal error" on both, to every token and + request, 2026-11), `load_catalog()` takes vavoo.to's channel index + (`load_vavoo_index()`: `VAVOO_INDEX_PATH` `/live2/index?...&output= + json` on `index_site`, user-agent `VAVOO/2.6`, no token; kool.to has + none). Its entries become catalog channels: the id from the play + address, `fix_geil_name()` on the name ("(1)/(6)/(7)" -> ".b/.c/.s", + so sources group as Geil's), `tvg_id` as `epg_id`, at least 100. Its + failure is only logged (`_index_error`): the status line keeps the + API's error. Its play addresses (`_is_vavoo_index_url()`, + `/live2/play3/.m3u8`) answer a 302 to a stream server, a new + address each time: `_resolve_vavoo_index()` asks once (no redirect + followed) and caches the `Location` like any resolve - no token for + the player, a recording (`resolve_own()`) or `prefetch()` + (`tests/test_vavoo_index.py`). - It listens on every address (bouquets and `/playlist.m3u` serve other devices), but its controls (`LOCAL_ONLY_PATHS`: `/shutdown`, `/refresh_token`) answer only the box itself (`is_loopback()`, 403 diff --git a/README.md b/README.md index 1d2fde8a..04956273 100644 --- a/README.md +++ b/README.md @@ -447,6 +447,14 @@ The local proxy has no on/off switch: every channel list and stream goes through minutes; its own list replaces the lent one as soon as it answers. A server error (HTTP 5xx) or a lost connection on vavoo.to tries kool.to too (before, only an HTTP 451 did). +- **Vavoo's catalog down**: when neither vavoo.to nor kool.to gives + Vavoo's catalog (both answered HTTP 500 "Internal error" to every + request in November 2026), the proxy loads vavoo.to's own channel + index instead (`/live2/index`, about 10 000 channels in 17 + countries, no token). Its channels play straight from vavoo.to, with + no token at all - recordings and the zap ahead too. vavoo.log says + "[Vavoo] catalog API: vavoo.to HTTP 500, kool.to HTTP 500 - using + vavoo.to's channel index: n channels". - **One proxy per box**: `/status` says which copy of the plugin serves (`instance`, `pid`, `module`, `version`). If the plugin's modules are loaded twice in one Enigma2 (seen on a box: the second copy held the diff --git a/tests/run_tests.py b/tests/run_tests.py index 4bad02c6..58f12ad0 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -51,7 +51,8 @@ "test_settings_welcome", "test_speedups", "test_store", - "test_two_copies") + "test_two_copies", + "test_vavoo_index") TIMEOUT = 600 diff --git a/tests/test_catalog_source.py b/tests/test_catalog_source.py index 313cbc26..b0701fa1 100644 --- a/tests/test_catalog_source.py +++ b/tests/test_catalog_source.py @@ -101,6 +101,8 @@ def fresh(geil=None): p.base_sites = list(SITES) p.base_site_index = 0 p._update_endpoints() + # (vavoo.to's channel index on the fake site too: it answers no GET) + p.index_site = SITES[0] def fake_geil(): if geil: diff --git a/tests/test_vavoo_index.py b/tests/test_vavoo_index.py new file mode 100644 index 00000000..f3491fbf --- /dev/null +++ b/tests/test_vavoo_index.py @@ -0,0 +1,252 @@ +# -*- coding: utf-8 -*- +"""Vavoo's catalog API (/mediahubmx-catalog.json) answered HTTP 500 +"Internal error" on vavoo.to and kool.to, to every token and request, so +"Vavoo/Kool only" had no channels; vavoo.to's channel index +(/live2/index) still answered, with play addresses that need no token +(a 302 to a stream server, another address each time). The proxy falls +back to it: the index's channels in the catalog's shape, their sources +grouped, played (and recorded, and prefetched) without a token, the +address kept for the whole viewing.""" +from __future__ import print_function +import json +import os +import socket +import sys +import threading + +HERE = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, HERE) +import harness # noqa: E402 +from harness import check, finish # noqa: E402 +plugin = harness.plugin +vp = plugin.vavoo_proxy +for key in ("http_proxy", "https_proxy", "HTTP_PROXY", "HTTPS_PROXY"): + os.environ.pop(key, None) +try: + from http.server import BaseHTTPRequestHandler, HTTPServer + from socketserver import ThreadingMixIn +except ImportError: + from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer + from SocketServer import ThreadingMixIn + +SIGS = [] +OWN = [] +vp.VavooProxy.refresh_addon_sig_if_needed = ( + lambda self, force=False: SIGS.append(1) or "sig") +vp.VavooProxy.own_signature = ( + lambda self, slot, force=False: OWN.append(slot) or "own") + +# ---------------------------------------------------------------- the site +STATE = {"api": 500, "index": 200, "index_n": 150, "play": 302} +HITS = {"api": 0, "index": 0, "play": 0} + + +def index_items(n): + play = "http://127.0.0.1:%d/a/live2/play3/%%s.m3u8" % SITE_PORT + items = [{"group": u"Portugal", "logo": u"/live2/logo/%d.png" % i, + "name": u"CANAL %d (6)" % i, "tvg_id": u"Canal%d.pt" % i, + "url": play % (1000 + i)} for i in range(n)] + items += [{"group": u"Germany", "logo": u"", "name": u"ARTE (%s)" % s, + "tvg_id": u"Arte.de", "url": play % (2000 + j)} + for j, s in enumerate(("7", "6", "1"))] + items += [{"group": u"Italy ➾ Sport", "logo": u"", "name": u"SKY (1)", + "tvg_id": u"", "url": play % 3000}, + {"group": u"Portugal", "name": u"No address"}, + u"not an entry"] + return items + + +def api_items(): + return [{"type": "iptv", "ids": {"id": "v%d" % i}, + "name": "Canal %d" % i, "url": "http://vavoo/%d" % i, + "group": u"Portugal", "logo": ""} for i in range(150)] + + +class Handler(BaseHTTPRequestHandler): + def answer(self, code, body=b"", headers=()): + self.send_response(code) + for name, value in headers: + self.send_header(name, value) + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def do_POST(self): + length = int(self.headers.get("content-length") or 0) + if length: + self.rfile.read(length) + HITS["api"] += 1 + if STATE["api"] == 200: + body = json.dumps({"items": api_items(), "nextCursor": None}) + return self.answer(200, body.encode("utf-8")) + self.answer(STATE["api"], b'{"error":"Internal error"}') + + def do_GET(self): + if "/live2/index" in self.path: + HITS["index"] += 1 + if STATE["index"] != 200: + return self.answer(STATE["index"], b"no") + body = json.dumps(index_items(STATE["index_n"])) + return self.answer(200, body.encode("utf-8"), + [("Content-Type", "application/json")]) + if "/live2/play3/" in self.path: + HITS["play"] += 1 + number = self.path.rsplit("/", 1)[1].split(".")[0] + if STATE["play"] == 302: + return self.answer(302, headers=[( + "Location", "http://127.0.0.1:%d/stream/%s?t=%d" % + (SITE_PORT, number, HITS["play"]))]) + return self.answer(STATE["play"], b"#EXTM3U\n") + self.answer(404) + + def log_message(self, *args): + pass + + +class Server(ThreadingMixIn, HTTPServer): + daemon_threads = True + + +server = Server(("127.0.0.1", 0), Handler) +SITE_PORT = server.server_address[1] +threading.Thread(target=server.serve_forever).start() +SITES = ["http://127.0.0.1:%d/a" % SITE_PORT, + "http://127.0.0.1:%d/b" % SITE_PORT] + + +def fresh(): + p = vp.VavooProxy() + p.base_sites = list(SITES) + p.base_site_index = 0 + p._update_endpoints() + p.index_site = SITES[0] + return p + + +def reset(**state): + STATE.update({"api": 500, "index": 200, "index_n": 150, "play": 302}) + STATE.update(state) + for name in HITS: + HITS[name] = 0 + + +print("== the catalog API fails: vavoo.to's channel index") +reset() +p = fresh() +items, source = p._download_catalog("vavoo") +check(source == "vavoo" and len(items) == 154, + "the index's channels, the broken entries left out: %d (%s)" % + (len(items), source)) +check(HITS["api"] >= 2 and HITS["index"] == 1, + "the API asked first (%d), then the index once (%d)" % + (HITS["api"], HITS["index"])) +check(vp.catalog_error_text(p.catalog_errors) == "", + "nothing wrong on the status line: %r" % p.catalog_errors) +by_id = dict((c["id"], c) for c in items) +first = by_id.get("1000") or {} +check(first.get("name") == u"CANAL 0 .c" and first.get("country") == + u"Portugal" and first.get("epg_id") == u"Canal0.pt", + "the id from the address, the source as a tag, the guide id: %r" % + first) +check(first.get("logo") == "https://vavoo.to/live2/logo/0.png", + "the logo's address: %r" % first.get("logo")) +names = sorted(c["name"] for c in items if c["country"] == u"Germany") +check(names == [u"ARTE .b", u"ARTE .c", u"ARTE .s"], + "(1) (6) (7) as .b .c .s: %r" % names) +check(by_id.get("3000", {}).get("country") == u"Italy", + "the country from the group: %r" % by_id.get("3000")) + +p._install_catalog(items, source) +arte = p._group_members("germany", vp._group_key(u"ARTE .s")) +check(len(arte) == 3, "the three ARTE sources are one group: %d" % len(arte)) + +print("== played without a token, one address for the whole viewing") +del SIGS[:] +url = first["url"] +check(vp._is_vavoo_index_url(url) and not vp._is_vavoo_index_url( + "http://vavoo/5") and not vp._is_vavoo_index_url(""), + "the index's play addresses are told apart") +s1 = p.resolve_with_retry(url) +s2 = p.resolve_with_retry(url) +check(s1 and s1.startswith("http://127.0.0.1:%d/stream/1000" % SITE_PORT), + "the stream server's address: %r" % s1) +check(s2 == s1 and HITS["play"] == 1, + "asked again: the same address, the site asked once (%d)" % + HITS["play"]) +check(SIGS == [], "no token asked: %r" % SIGS) + +vp.proxy = p +proxy_server = vp.ThreadedHTTPServer(("127.0.0.1", 0), vp.VavooHTTPHandler) +threading.Thread(target=proxy_server.serve_forever).start() +PROXY_PORT = proxy_server.server_address[1] + + +def proxy_get(path): + s = socket.create_connection(("127.0.0.1", PROXY_PORT), timeout=10) + s.sendall(("GET %s HTTP/1.0\r\nHost: x\r\n\r\n" % path).encode("ascii")) + data = b"" + while True: + chunk = s.recv(4096) + if not chunk: + break + data += chunk + s.close() + return data.decode("latin-1") + + +answer = proxy_get("/vavoo?channel=1000") +check(answer.startswith("HTTP/1.0 302") or answer.startswith("HTTP/1.1 302"), + "/vavoo answers a redirect: %r" % answer[:40]) +check(("Location: " + s1) in answer, "to the same stream address") +group_id = vp.make_group_id("germany", vp._group_key(u"ARTE .s")) +answer = proxy_get("/vavoo?channel=" + group_id) +check(" 302" in answer.split("\r\n", 1)[0] and "/stream/200" in answer, + "a group plays one of its sources: %r" % answer[:120]) +check(SIGS == [], "still no token: %r" % SIGS) + +print("== a recording and the zap ahead need no token either") +plays = HITS["play"] +own = p.resolve_own("1000", "rec-1") +check(own and "/stream/1000" in own and own != s1 and OWN == [], + "the recording gets its own address, no token: %r %r" % (own, OWN)) +check(p.resolve_with_retry(url) == s1, + "the player's address is not touched") +check(p.prefetch("1001") and HITS["play"] == plays + 2, + "the next channel resolved ahead (%d)" % HITS["play"]) +check(p.resolve_with_retry(by_id["1001"]["url"]) and + HITS["play"] == plays + 2, "and taken from the cache when zapped to") + +print("== a play address that answers itself, or not at all") +reset(play=200) +check(p.resolve_with_retry(by_id["1002"]["url"]) == by_id["1002"]["url"], + "a 200: the address itself") +reset(play=404) +check(p.resolve_with_retry(by_id["1003"]["url"]) is None, + "a 404: nothing to play") + +print("== the API answering again comes first") +reset(api=200) +p = fresh() +items, source = p._download_catalog("vavoo") +check(len(items) == 150 and items[0]["id"] == "v0" and HITS["index"] == 0, + "the API's catalog, the index not asked (%d, %d)" % + (len(items), HITS["index"])) + +print("== the index fails too: the API's error on the status line") +reset(index=500) +p = fresh() +items, source = p._download_catalog("vavoo") +check(items == [] and vp.catalog_error_text(p.catalog_errors) == + "Vavoo: HTTP 500", "no channels, %r" % + vp.catalog_error_text(p.catalog_errors)) +check("index HTTP 500" in p._index_error, + "why the index failed is kept: %r" % p._index_error) +reset(index_n=50) +p = fresh() +items, source = p._download_catalog("vavoo") +check(items == [] and "only" in p._index_error, + "an index of a few channels is not taken: %r" % p._index_error) + +proxy_server.shutdown() +server.shutdown() +finish() diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md index 1d2fde8a..04956273 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md @@ -447,6 +447,14 @@ The local proxy has no on/off switch: every channel list and stream goes through minutes; its own list replaces the lent one as soon as it answers. A server error (HTTP 5xx) or a lost connection on vavoo.to tries kool.to too (before, only an HTTP 451 did). +- **Vavoo's catalog down**: when neither vavoo.to nor kool.to gives + Vavoo's catalog (both answered HTTP 500 "Internal error" to every + request in November 2026), the proxy loads vavoo.to's own channel + index instead (`/live2/index`, about 10 000 channels in 17 + countries, no token). Its channels play straight from vavoo.to, with + no token at all - recordings and the zap ahead too. vavoo.log says + "[Vavoo] catalog API: vavoo.to HTTP 500, kool.to HTTP 500 - using + vavoo.to's channel index: n channels". - **One proxy per box**: `/status` says which copy of the plugin serves (`instance`, `pid`, `module`, `version`). If the plugin's modules are loaded twice in one Enigma2 (seen on a box: the second copy held the diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py index 93026c20..18dd1c8a 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py @@ -954,6 +954,27 @@ def fix_geil_name(name): return stripped[:m.start()].rstrip() + " ." + tag +# vavoo.to's own channel index: every channel with its group, a guide id +# (tvg_id), a logo and a play address, no token. Vavoo's catalog API +# (/mediahubmx-catalog.json) answered HTTP 500 "Internal error" on both +# sites, to every token and request (2026-11), while this list answered +# (10 000+ entries, 17 countries) - load_catalog() falls back to it. +# Names carry geil.to's "(N)" source numbers (fix_geil_name()). A play +# address (/live2/play3/.m3u8) answers a 302 to a stream server, a +# different address each time: _resolve_vavoo_index() takes it once and +# keeps it like any resolved address. kool.to has no such list. +VAVOO_INDEX_SITE = BASE_SITES[0] +VAVOO_INDEX_PATH = "/live2/index?countries=all&output=json" +VAVOO_INDEX_AGENT = "VAVOO/2.6" +_VAVOO_INDEX_PLAY_RE = re.compile(r'/live2/play\d*/([^/?#]+?)(?:\.m3u8)?$') + + +def _is_vavoo_index_url(url): + """A play address of vavoo.to's channel index (needs no token).""" + return bool(url) and "/live2/play" in url and bool( + _VAVOO_INDEX_PLAY_RE.search(url.split("?", 1)[0])) + + # Channel grouping (like the companion Android app's "group sources" # option): several catalog entries are really the same channel from # different sources, distinguished only by a trailing Vavoo-style @@ -1279,6 +1300,10 @@ def __init__(self): self.geil_sites = list(GEIL_SITES) self.geil_site_index = 0 self.catalog_source = "vavoo" + # vavoo.to's channel index, when its catalog API gives nothing + # (load_vavoo_index()) + self.index_site = VAVOO_INDEX_SITE + self._index_error = "" # Per grouped (multi-source) channel, guarded by group_lock: # group_id -> {"member": id of the source it is playing from, @@ -1611,6 +1636,14 @@ def resolve_own(self, channel_id, slot, force=False): if stream_url: return stream_url return None + if all(_is_vavoo_index_url(m.get("url")) for m in candidates): + # (vavoo.to's channel index: no token) + for member in candidates: + stream_url = self._resolve_vavoo_index( + member.get("url"), 2, cache=False) + if stream_url: + return stream_url + return None if not self.own_signature(slot, force=force): return None for member in candidates: @@ -2029,7 +2062,10 @@ def load_catalog(self, sig): before, only an HTTP 451 did, and an HTTP 500 from vavoo.to ended there with no list. Each site's failure is kept in self._vavoo_error ("vavoo.to HTTP 500, kool.to HTTP 500") for - catalog_errors. [] when no site gave a list.""" + catalog_errors. When no site gives it, vavoo.to's channel index + (load_vavoo_index(): no token, its own play addresses); its + failure is only logged - the status line keeps saying why the + catalog failed. [] when neither gave a list.""" errors = [] tries = max(1, len(self.base_sites)) for attempt in range(tries): @@ -2044,9 +2080,66 @@ def load_catalog(self, sig): errors.append("%s %s" % (site, failed)) if attempt < tries - 1: self._switch_to_next_base("(catalog: %s)" % failed) + channels = self.load_vavoo_index() + if channels: + print("[Vavoo] catalog API: %s - using %s's channel index: " + "%d channels" % (", ".join(errors), + site_name(self.index_site), + len(channels))) + self._vavoo_error = "" + return channels self._vavoo_error = ", ".join(errors) return [] + def load_vavoo_index(self): + """vavoo.to's channel index (VAVOO_INDEX_PATH, no token) as + channels in the catalog loaders' shape: the id from the play + address, the name with its source number as a tag + (fix_geil_name(): "ARTE (7)" -> "ARTE .s", so sources group and + show like the others), the guide id (tvg_id) as epg_id. None + when it gives no list (why in self._index_error, and the log).""" + url = self.index_site.rstrip('/') + VAVOO_INDEX_PATH + try: + r = self.session.get( + url, headers={"user-agent": VAVOO_INDEX_AGENT, + "accept": "application/json"}, + timeout=60, stream=False) + r.raise_for_status() + data = decode_response(r) + if not isinstance(data, list): + raise ValueError("no channel list") + channels = [] + # (a background thread: it gives way while a stream plays) + breather = _Breather() + for item in data: + breather.tick() + try: + play = item.get("url") + m = _VAVOO_INDEX_PLAY_RE.search( + (play or "").split("?", 1)[0]) + if not m or not item.get("name"): + continue + group = item.get("group") or "" + channels.append({ + "country": _base_country_from_group(group), + "id": str(m.group(1)), + "name": fix_geil_name(item.get("name")), + "url": play, + "logo": fix_logo_url(item.get("logo") or ""), + "group": group, + "epg_id": item.get("tvg_id") or ""}) + except Exception as e: + print("[Vavoo] Skipping malformed index item: {0}".format(e)) + if len(channels) < 100: + raise IOError("only %d channels" % len(channels)) + self._index_error = "" + return channels + except Exception as e: + self._index_error = "%s index %s" % ( + site_name(self.index_site), short_error(e)) + print("[Vavoo] No channel index from %s: %s" % (url, e)) + return None + def _load_catalog_site(self, sig): """The complete catalog from the current site, with improved error handling including JSON decode errors. Why its first page @@ -2428,8 +2521,9 @@ def prefetch(self, channel_id): no group state (a group's source is the one it would try first, read with _ordered_group_members(), which only reads). Unused, the address is forgotten after RESOLVE_IDLE_TTL. One at a time. - True when an address is ready.""" - if self.catalog_source != "geil" or not channel_id: + Also on vavoo.to's channel index (its play addresses need no + token either). True when an address is ready.""" + if not channel_id: return False if not self._prefetch_lock.acquire(False): return False @@ -2444,6 +2538,9 @@ def prefetch(self, channel_id): url = channel.get("url") if channel else None if not url: return False + if self.catalog_source != "geil" and \ + not _is_vavoo_index_url(url): + return False if self._get_cached_url(url): return True return bool(self.resolve_with_retry(url, max_retries=1)) @@ -2805,6 +2902,48 @@ def _cache_resolved_url(self, channel_url, stream_url): if now - v["ts"] >= self.resolve_cache_ttl]: self.resolve_cache.pop(key, None) + def _resolve_vavoo_index(self, channel_url, max_retries, cache=True): + """A play address of vavoo.to's channel index -> the stream + server's address it redirects to, no token. Each request there + gives a different address, so it is asked once and kept like any + resolved address (cache; a recording's is not cached). A 200 + (no redirect) plays the address itself.""" + last_exception = None + for attempt in range(max(1, max_retries)): + try: + r = self.session.get( + channel_url, + headers={"user-agent": VAVOO_INDEX_AGENT, + "accept": "*/*"}, + timeout=15, allow_redirects=False) + try: + code = r.status_code + location = r.headers.get("location") or "" + finally: + r.close() + stream_url = None + if code in (301, 302, 303, 307, 308) and \ + location.startswith(("http://", "https://")): + stream_url = location + elif code == 200: + stream_url = channel_url + if stream_url: + if cache: + self._cache_resolved_url(channel_url, stream_url) + return stream_url + print("[Vavoo] Index play address answered HTTP %s " + "(attempt %d/%d)" % (code, attempt + 1, max_retries)) + except Exception as e: + last_exception = e + print("[Vavoo] Index play address failed (attempt %d/%d): %s" + % (attempt + 1, max_retries, e)) + if attempt < max_retries - 1: + select.select([], [], [], 1) + if last_exception: + print("[Vavoo] Failed to resolve {0}: {1}".format( + channel_url, last_exception)) + return None + def _resolve_geil_channel(self, channel_url, max_retries, cache=True): """Resolve a geil.to channel's stream address - GET {base}/live/resolve?url=, no token at all. @@ -2858,6 +2997,9 @@ def _do_resolve_with_retry(self, channel_url, max_retries, slot=None): resolve_with_retry() for the in-flight dedup wrapping this. slot: with that slot's own token (resolve_own()), the answer not cached.""" + if _is_vavoo_index_url(channel_url): + return self._resolve_vavoo_index( + channel_url, max_retries, cache=slot is None) if self.catalog_source == "geil" and slot is None: return self._resolve_geil_channel(channel_url, max_retries) for attempt in range(max_retries): From 9ba28193e7d13991c76bcf869e06f5ffa11c7604 Mon Sep 17 00:00:00 2001 From: pQu4k3r Date: Sun, 29 Nov 2026 22:56:52 +0000 Subject: [PATCH 2/3] Cleanup: no token pinged for nothing, the code nothing calls removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The user: clean up the code that no longer serves - Vavoo's catalog API and its token are kept (its HTTP 500 may pass; the plugin goes back to it by itself), the rest removed. A token only where it is needed: - With vavoo.to's channel index in use the token monitor still renewed Vavoo's token every ~8 min for ever, and every recording kept a token of its own alive (on Geil's list too) - nothing used them. /status and /health said token_required whenever the list was not Geil's. - _install_catalog() sets token_required (a Vavoo list with an address that is not one of the index's; an empty one counts), needs_token() reads it (never on Geil): /status, /health and the monitor (_token_monitor_tick(), the loop's body, testable) go by it. channel_needs_token(channel_id) (_channel_candidates(), shared with resolve_own()) for a recording's keep-alive in ui_record. - The status line names the source by catalog_source (SOURCE_NAMES), no longer by token_required - the index's list stays "✓ Vavoo OK". Removed (nothing in the plugin called them; vulture + grep): paypal(), _bouquet_country_prefix(), the notification module's show_notification / show_download_notification (+ show_download_status) / hide_current_notification / cleanup_notifications, unregister_file(), color_for(), download_flag_online() and then get_screen_width(), VavooSearch's toggleCase() / updateStatusText() / upper_case, manage_epg_source() and its import. Kept: folder_of() (the store's API the tests use) and the methods Enigma2 calls by name. - tests/test_vavoo_index.py: no token on the index's list (/status, a recording, a group), an old token not renewed for it, renewed on the API's list, none on Geil's; the status line. Checks of the removed helpers dropped (test_py2_separators, py2_smoke uses hue_for()). - Against the real vavoo.to: "READY 10349 channels (vavoo)", /status token_required false, /health healthy. - CLAUDE.md, README / readme. --- CLAUDE.md | 11 ++ README.md | 2 +- tests/py2_smoke.py | 2 +- tests/test_py2_separators.py | 4 - tests/test_vavoo_index.py | 35 +++++ .../Plugins/Extensions/vavoo/__init__.py | 7 - .../Extensions/vavoo/bouquet_manager.py | 21 --- .../Extensions/vavoo/notification_system.py | 67 +-------- .../python/Plugins/Extensions/vavoo/plugin.py | 27 +--- .../python/Plugins/Extensions/vavoo/readme.md | 2 +- .../Plugins/Extensions/vavoo/ui_record.py | 7 +- .../Plugins/Extensions/vavoo/ui_settings.py | 7 - .../python/Plugins/Extensions/vavoo/vUtils.py | 140 +----------------- .../Plugins/Extensions/vavoo/vavoo_proxy.py | 107 +++++++++---- .../Plugins/Extensions/vavoo/vavoo_record.py | 5 - .../Plugins/Extensions/vavoo/vavoo_store.py | 4 - 16 files changed, 142 insertions(+), 306 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 78f165dd..337dbab1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -316,6 +316,17 @@ on `127.0.0.1:4323`. It: touches the shared resolve cache or the group state (the player keeps its address); geil needs no token. The ping itself is `_request_addon_sig()`, shared with `refresh_addon_sig_if_needed()`. +- A token only where it is needed: `token_required` (set by + `_install_catalog()`: a Vavoo list with an address that is not one of + vavoo.to's channel index; an empty Vavoo list counts), read through + `needs_token()` (never on Geil), is what `/status` / `/health` say + and what the token monitor + (`_token_monitor_tick()`) renews for - not on Geil's list nor the + index, where it was pinged every few minutes for nothing. A + recording's keep-alive asks `channel_needs_token(channel_id)` (its + sources, `_channel_candidates()`) before `own_signature()`. The + status line names the source by `catalog_source` + (`SOURCE_NAMES`), never by `token_required`. - `/file?id=&offset=[&follow=1]` serves only ids registered with `vavoo_record.register_file()` - never a path (the proxy answers the LAN for bouquets). `offset` is rounded down to a 188-byte packet, a diff --git a/README.md b/README.md index 04956273..cd151988 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,7 @@ The local proxy has no on/off switch: every channel list and stream goes through version. This can't recover a source that resolved fine but is slow/buffering - pick another one for that. -- **Token Monitor**: Background thread that checks token age every 60 seconds +- **Token Monitor**: Background thread that checks token age every 60 seconds, and renews it only while the list in use plays through Vavoo's token (not on Geil's list nor vavoo.to's channel index - `/status` says `token_required`); recordings keep a token of their own only where it is needed too - **Active Stream Tracking**: Notifies proxy when streams start/end for better resource management ### EPG Integration diff --git a/tests/py2_smoke.py b/tests/py2_smoke.py index 669ff485..d4c0c950 100644 --- a/tests/py2_smoke.py +++ b/tests/py2_smoke.py @@ -162,7 +162,7 @@ def run(what, fn): print("== initials, colours, search, drawn pictures") check(run("initials", lambda: store.initials(U)) == u"RS", "initials of %r" % U) -run("colour", lambda: store.color_for(B)) +run("colour", lambda: store.hue_for(B)) items = [U, u"TF1 Séries", "Canale 5"] found = run("search", lambda: store.search(items, u"sudtirol")) check(found == [U], "search without the accent finds it: %r" % (found,)) diff --git a/tests/test_py2_separators.py b/tests/test_py2_separators.py index 470f96bb..d5236272 100644 --- a/tests/test_py2_separators.py +++ b/tests/test_py2_separators.py @@ -34,10 +34,6 @@ "hierarchical") == "userbouquet.vavoo_italy_sport.tv", "_build_bouquet_filename(%s)" % label) - check( - bm._bouquet_country_prefix(name) == "italy", - "_bouquet_country_prefix(%s)" % - label) check( bm.is_bouquet_exported(name) in ( True, diff --git a/tests/test_vavoo_index.py b/tests/test_vavoo_index.py index f3491fbf..953cb2e4 100644 --- a/tests/test_vavoo_index.py +++ b/tests/test_vavoo_index.py @@ -216,6 +216,41 @@ def proxy_get(path): check(p.resolve_with_retry(by_id["1001"]["url"]) and HITS["play"] == plays + 2, "and taken from the cache when zapped to") +print("== no token kept alive for a list that plays without one") +check(p.token_required is False and + vp.status_of(p)["token_required"] is False, + "the index's list needs no token (/status too)") +check(p.channel_needs_token("1000") is False and + p.channel_needs_token(group_id) is False, + "nor a recording of one of its channels, a group's either") +p.addon_sig_data = {"sig": "old", "ts": 0} +del SIGS[:] +check(p._token_monitor_tick() is False and SIGS == [], + "an old token is not renewed for nothing: %r" % SIGS) +status = plugin.proxy_status_text(dict(vp.status_of(p), ready=True)) +check(status == u"✓ Vavoo OK · 154 ch" or plugin.to_text(status) == + u"✓ Vavoo OK · 154 ch", + "the status line: Vavoo, no token complaint: %r" % status) +api = fresh() +api._install_catalog( + [{"id": "v%d" % i, "name": "Canal %d" % i, "url": "http://vavoo/%d" % i, + "country": "Portugal", "logo": "", "group": "Portugal", + "epg_id": ""} for i in range(150)], "vavoo") +api._stop_event.set() # (its own monitor thread: the tick alone here) +api.addon_sig_data = {"sig": "old", "ts": 0} +del SIGS[:] +check(api.token_required is True and api.channel_needs_token("v1"), + "the API's list plays through the token") +check(api._token_monitor_tick() is True and SIGS == [1], + "its old token is renewed: %r" % SIGS) +geil = fresh() +geil._install_catalog(list(api.all_filtered_items), "geil") +check(geil.token_required is False and not geil.channel_needs_token("v1"), + "Geil's list: no token") +rec_source = harness.e2env.source_of("_Recordings") +check("channel_needs_token" in rec_source, + "a recording keeps its own token alive only where it is needed") + print("== a play address that answers itself, or not at all") reset(play=200) check(p.resolve_with_retry(by_id["1002"]["url"]) == by_id["1002"]["url"], diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py index 9424d899..f51d333a 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py @@ -144,13 +144,6 @@ def _init_log(msg, level="INFO"): pass -def paypal(): - conthelp = "If you like what I do you\n" - conthelp += "can contribute with a coffee\n" - conthelp += "scan the qr code and donate € 1.00" - return conthelp - - isDreamOS = False if os.path.exists("/usr/bin/apt-get"): isDreamOS = True diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/bouquet_manager.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/bouquet_manager.py index b58a850a..26960805 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/bouquet_manager.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/bouquet_manager.py @@ -1021,27 +1021,6 @@ def _build_bouquet_filename(name_for_path, export_type): return "userbouquet.vavoo_%s_%s.tv" % (country_safe, category_safe) -def _bouquet_country_prefix(name_for_path): - """The sanitized country-name prefix _build_bouquet_filename() would - use for a category sub-bouquet's filename (e.g. "italy" out of - "Italy -> Sport"), or None if name_for_path isn't a "country - category" name at all. - - Used by remove_bouquets_by_name() to tell whether a sibling category - bouquet for the same country still exists on disk before deleting - that country's shared EPG channels.xml file. - """ - for sep in group_separators(name_for_path): - if sep in name_for_path: - parts = name_for_path.split(sep) - country_part = parts[0].strip() - category_part = parts[1].strip() - if country_part and category_part: - return country_part.lower().replace(' ', '_') - break - return None - - def create_fallback_bouquet_sync( servicetype, name, diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/notification_system.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/notification_system.py index cddc166c..7f8ebb7a 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/notification_system.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/notification_system.py @@ -253,33 +253,6 @@ def showMessage(self, message, duration=3000): reactor.callFromThread(self._showMessage, message, duration) - def show_download_status(self, title, status, file_size=0): - """Display a download status notification""" - icons = { - 'completed': u'✅', - 'error': u'❌', - 'downloading': u'🚀', - 'paused': u'⏸️', - 'queued': u'📥' - } - - icon = icons.get(status, u'ℹ️') - - if status == 'completed' and file_size > 0: - size_mb = float(file_size) / (1024.0 * 1024.0) - message = u"{} {}\nCompleted - {:.1f}MB".format( - icon, title, size_mb) - elif status == 'downloading': - message = u"{} Downloading\n{}".format(icon, title) - elif status == 'error': - message = u"{} Download error\n{}".format(icon, title) - elif status == 'paused': - message = u"{} Download paused\n{}".format(icon, title) - else: - message = u"{} {}".format(icon, title) - - self.showMessage(message, 5000) - def show(self, message, seconds=3): """Simplified version with duration in seconds""" self.showMessage(message, seconds * 1000) @@ -311,22 +284,6 @@ def init_notification_system(session): _notification_manager._processPendingMessages() -def show_notification(message, duration=3000): - """ - Show a notification message (thread-safe) - - Args: - message (str): Text to display - duration (int): Display duration in milliseconds (default: 3000) - """ - _notification_manager.showMessage(message, duration) - - -def show_download_notification(title, status, file_size=0): - """Show download-specific notification""" - _notification_manager.show_download_status(title, status, file_size) - - def quick_notify(message, seconds=3): """ Quick notification with duration in seconds @@ -338,23 +295,12 @@ def quick_notify(message, seconds=3): _notification_manager.show(message, seconds) -def hide_current_notification(): - """Hide the current notification immediately""" - _notification_manager.hide() - - -def cleanup_notifications(): - """Clean up notifications when plugin closes""" - _notification_manager.hide() - print("Cleanup complete") - - # ============================================================================= # USAGE EXAMPLES - How to use in your plugins # ============================================================================= """ -from .notification_system import init_notification_system, quick_notify, show_notification +from .notification_system import init_notification_system, quick_notify # 1. INITIALIZATION (in your main plugin class) class MyPlugin(Screen): @@ -364,21 +310,12 @@ def __init__(self, session): init_notification_system(session) # 2. BASIC USAGE -# Show 3-second notification -show_notification("Processing completed!") - -# Show 5-second notification -show_notification("Download finished", 5000) - -# Simplified version (seconds instead of milliseconds) +# Show a 3-second notification quick_notify("File saved successfully") # Longer notification quick_notify("Backup completed successfully", 5) -# Hide manually if needed -hide_current_notification() - # 3. AFTER OPERATIONS def on_download_finished(self, success, filename): if success: diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/plugin.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/plugin.py index c5ca0db5..3b164f54 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/plugin.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/plugin.py @@ -560,9 +560,13 @@ def proxy_status_text(state, channel_total=None): return _("✗ No channels") + " - " + to_string(why) return _("✗ No channels") # Geil (the default catalog source) needs no addonSig token at all, - # so addon_sig_valid is always False on it - not a problem there. + # nor vavoo.to's channel index - addon_sig_valid / its age mean + # nothing there. The source's name comes from catalog_source (the + # index is Vavoo's, with no token). token_required = state.get("token_required", True) - source = "Vavoo" if token_required else "Geil" + source = vavoo_proxy.SOURCE_NAMES.get( + state.get("catalog_source"), + "Vavoo" if token_required else "Geil") channels = channel_total or state.get("channels_count", 0) if token_required and not state.get("addon_sig_valid", False): return _("✗ Proxy Error") @@ -4394,7 +4398,6 @@ def __init__(self, session, parentScreen, itemlist, scope=None, self.numericalInput = NumericalTextInput( nextFunc=self.searchWithString) self.input_active = False - self.upper_case = False self.last_key = None self.search_text = "" self.last_key_time = 0 @@ -4478,24 +4481,6 @@ def onKeyboardClosed(self, result): self["search_text"].setText(self.search_text) self.updateFilteredList() - def toggleCase(self): - """Toggle between uppercase and lowercase""" - self.upper_case = not self.upper_case - case_text = _("UPPERCASE") if self.upper_case else _("lowercase") - self["status"].setText(_("Case: {}").format(case_text)) - - def updateStatusText(self): - """Update status text""" - if self.search_text: - # Separa in parti senza virgolette - part1 = _("Search:") - part2 = _('Found: {} channels').format(len(self.filteredList)) - message = '{0} "{1}" - {2}'.format(part1, self.search_text, part2) - self["status"].setText(message) - else: - self["status"].setText( - _("Showing all channels: {}").format(len(self.filteredList))) - def updateFilteredList(self): """The app's search (vavoo_store.search_matches()): every word at the start of a word of the name, or (3+ letters) anywhere; diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md index 04956273..cd151988 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md @@ -514,7 +514,7 @@ The local proxy has no on/off switch: every channel list and stream goes through version. This can't recover a source that resolved fine but is slow/buffering - pick another one for that. -- **Token Monitor**: Background thread that checks token age every 60 seconds +- **Token Monitor**: Background thread that checks token age every 60 seconds, and renews it only while the list in use plays through Vavoo's token (not on Geil's list nor vavoo.to's channel index - `/status` says `token_required`); recordings keep a token of their own only where it is needed too - **Active Stream Tracking**: Notifies proxy when streams start/end for better resource management ### EPG Integration diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_record.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_record.py index 8bf9970c..973e9baf 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_record.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_record.py @@ -535,7 +535,12 @@ def address(force): return vavoo_proxy.proxy.resolve_own(channel_id, slot, force) def keep_alive(): - vavoo_proxy.proxy.own_signature(slot) + # (a token of its own only where it plays through one: not + # Geil's list, nor vavoo.to's channel index) + p = vavoo_proxy.proxy + needs = getattr(p, "channel_needs_token", None) + if needs is None or needs(channel_id): + p.own_signature(slot) recorder = vavoo_record.Recorder( address, path, stop_at=stop_at, max_seconds=max_seconds, diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_settings.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_settings.py index 15bfcd74..574fc522 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_settings.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/ui_settings.py @@ -62,7 +62,6 @@ from .vUtils import ( debug, make_print, - update_epg_sources, ensure_vavoo_epg_sources_enabled, decodeHtml, ensure_str, @@ -1143,12 +1142,6 @@ def get_countries_from_proxy(self): return [] - def manage_epg_source(self): - # Just call the static function from vUtils - # This will generate EPG from all existing bouquets - # return generate_epg_files() - return update_epg_sources() - def setInfo(self): try: sel = self['config'].getCurrent()[2] diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vUtils.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vUtils.py index c0638a97..cc48fedb 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vUtils.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vUtils.py @@ -466,19 +466,6 @@ def _note_second_copy(): _dns_info_thread.start() -def get_screen_width(): - """Get current screen width""" - try: - from enigma import getDesktop - desktop = getDesktop(0) - width = desktop.size().width() - print("Screen width detected: %d" % width) - return width - except Exception as e: - print("Error getting screen width: %s" % str(e)) - return 1920 - - class AspectManager(object): """Manages aspect ratio settings for the plugin""" @@ -1310,128 +1297,6 @@ def initialize_cache_with_local_flags(): return copied -def download_flag_online( - country_name, - cache_dir=FLAG_CACHE_DIR, - screen_width=None): - """ - Download country flag from online service (TV Garden style) - Returns: (success, flag_path_or_error_message) - """ - try: - # 1. Determine screen width if not provided - if screen_width is None: - screen_width = get_screen_width() # must return int - - print( - "Processing %s with screen_width=%d" % - (country_name, screen_width)) - - # 2. Get country code - country_code = get_country_code(country_name) - if not country_code: - return False, "No country code found for: %s" % country_name - - country_code_lower = country_code.lower() - special_flags = ['bk', 'internat'] - - if country_code_lower in special_flags: - local_path = join( - PLUGIN_PATH, - 'skin/cowntry', - '%s.png' % - country_code_lower) - if exists(local_path): - print( - "Using special flag: %s -> %s" % - (country_name, local_path)) - return True, local_path - - # 3. Create cache directory (Python 2 safe) - if not exists(cache_dir): - try: - makedirs(cache_dir) - except Exception as e: - debug( - "Could not create flag cache dir {}: {}".format( - cache_dir, e)) - - # 4. Cache file path - cache_file = join(cache_dir, "%s.png" % country_code_lower) - - # 5. Check fresh cache (<7 days) - if exists(cache_file): - try: - file_age = time() - getmtime(cache_file) - if file_age < 604800: - print("Cache HIT: %s" % country_name) - return True, cache_file - except Exception as e: - debug("Flag cache freshness check failed for {}: {}".format( - cache_file, e)) - - # 6. Set fixed flag dimensions - if screen_width >= 2560: # WQHD - width, height = 80, 60 - elif screen_width >= 1920: # FHD - width, height = 60, 45 - else: # HD - width, height = 40, 30 - - # 7. Build URL - url = "https://flagcdn.com/%dx%d/%s.png" % ( - width, height, country_code_lower) - print("Downloading %s (%dx%d) from: %s" % - (country_name, width, height, url)) - - # 8. Download - req = Request(url, headers={'User-Agent': 'Vavoo-Stream/1.0'}) - try: - if PY3: - response = urlopen(req, timeout=5, context=ssl_context) - else: - response = urlopen(req, timeout=5) - except Exception as e: - print("Network error for %s: %s" % (country_name, e)) - return False, "Network error: %s" % e - - # 9. Read data - if response.getcode() != 200: - return False, "Download failed (HTTP %d)" % response.getcode() - flag_data = response.read() - try: - response.close() - except Exception: - pass - - # 10. Validate small file - if len(flag_data) < 100: - print( - "Warning: Flag file too small (%d bytes)" % - len(flag_data)) - - # 11. Validate PNG header in memory BEFORE writing (no double file - # open) - if flag_data[:8] != b'\x89PNG\r\n\x1a\n': - print("ERROR: Downloaded data is not a valid PNG file!") - return False, "Invalid PNG file downloaded" - - # 12. Save to cache - try: - _write_file_atomic(cache_file, flag_data) - print("Flag %dx%d saved: %s (%d bytes)" % - (width, height, cache_file, len(flag_data))) - return True, cache_file - - except Exception as e: - print("Error saving to cache: %s" % e) - return False, "Save error: %s" % e - - except Exception as e: - print("Flag download error: %s" % e) - return False, "Flag download error: %s" % e - - # ============================================================================ # PICON DOWNLOAD FUNCTIONS # ============================================================================ @@ -1686,9 +1551,8 @@ def cpu_report(before, after, elapsed): def download_picon_online(logo_url, cache_dir=None): """Download and cache a channel picon from its catalog-provided logo URL (geil.to's own picons, or Vavoo's - see vavoo_proxy.py's - fix_logo_url()). Mirrors download_flag_online()'s mechanics - (timeout, cache-dir creation, PNG-header validation before - writing) for the same reasons - including graceful failure: if + fix_logo_url()): a timeout, the cache folder made when missing, the + PNG header checked before writing - and graceful failure: if the URL doesn't actually serve a valid PNG, this just reports failure and the caller keeps showing its default icon, same as before this existed. diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py index 18dd1c8a..6da19ee3 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_proxy.py @@ -754,12 +754,11 @@ def status_of(p): "initialized": p.initialized, "channels_count": len(p.all_filtered_items), "catalog_source": p.catalog_source, - # geil.to needs no token at all, so addon_sig_valid is - # permanently false and addon_sig_age a huge nonsense number on - # that source - this flag tells a consumer not to treat either - # as a problem, same disambiguation /health's "status" field - # already makes internally. - "token_required": p.catalog_source != "geil", + # geil.to needs no token at all, nor vavoo.to's channel index, + # so addon_sig_valid / addon_sig_age mean nothing there - this + # flag tells a consumer not to treat either as a problem, same + # disambiguation /health's "status" field makes. + "token_required": p.needs_token(), "addon_sig_valid": addon_sig["sig"] is not None, "addon_sig_age": int(time.time() - addon_sig["ts"]), # why there is no list of the catalog source ("Vavoo: HTTP @@ -1300,6 +1299,10 @@ def __init__(self): self.geil_sites = list(GEIL_SITES) self.geil_site_index = 0 self.catalog_source = "vavoo" + # whether the catalog in use plays through Vavoo's token (its + # API's list); not Geil's, nor vavoo.to's channel index - set by + # _install_catalog(), read by the token monitor and /status + self.token_required = True # vavoo.to's channel index, when its catalog API gives nothing # (load_vavoo_index()) self.index_site = VAVOO_INDEX_SITE @@ -1394,6 +1397,32 @@ def _robust_request(self, method, url, **kwargs): print(" Error on " + str(url) + ": " + str(e)) raise + def needs_token(self): + """Whether the catalog in use plays through Vavoo's token: + never Geil's, nor a list of vavoo.to's channel index + (token_required, set by _install_catalog()).""" + return self.catalog_source != "geil" and self.token_required + + def _token_monitor_tick(self): + """One check of the token monitor: a token older than + TOKEN_REFRESH_AGE is renewed - only while the catalog in use + plays through it (token_required: not on Geil's list nor + vavoo.to's channel index, where it would be pinged for nothing + every few minutes). True when it renewed.""" + now = time.time() + renewed = False + token_age = (now - self.addon_sig_data["ts"] + if self.addon_sig_data["sig"] else 0) + if self.needs_token() and self.addon_sig_data["sig"] and \ + token_age > TOKEN_REFRESH_AGE: + print( + "[Token Monitor] Token old ({}s), refreshing...".format( + int(token_age))) + self.refresh_addon_sig_if_needed(force=True) + renewed = True + self.last_heartbeat = now + return renewed + def start_token_monitor(self): """Monitor token age with minimal background traffic""" def token_monitor_loop(): @@ -1401,15 +1430,7 @@ def token_monitor_loop(): while not self._stop_event.is_set(): # Check FIRST, then sleep (first check is immediate at startup) try: - now = time.time() - token_age = (now - self.addon_sig_data["ts"] - if self.addon_sig_data["sig"] else 0) - if self.addon_sig_data["sig"] and token_age > TOKEN_REFRESH_AGE: - print( - "[Token Monitor] Token old ({}s), refreshing...".format( - int(token_age))) - self.refresh_addon_sig_if_needed(force=True) - self.last_heartbeat = now + self._token_monitor_tick() except Exception as e: print("[Token Monitor] Error: " + str(e)) @@ -1611,6 +1632,32 @@ def drop_own_signature(self, slot): with self._own_sig_lock: self._own_sigs.pop(slot, None) + def _channel_candidates(self, channel_id): + """The catalog entries a channel id plays from: a group's + sources in resolve_group_with_retry()'s order, else the one + channel; [] when unknown.""" + if not channel_id: + return [] + if channel_id.startswith(GROUP_ID_PREFIX): + country, key = parse_group_id(channel_id) + members = self._group_members(country, key) if key else [] + return self._ordered_group_members(channel_id, members) + channel = self.channels_by_id.get(channel_id) + return [channel] if channel else [] + + def channel_needs_token(self, channel_id): + """Whether a recording of channel_id needs a token of its own + (resolve_own()): not on Geil's list, nor when all its sources + are vavoo.to's channel index addresses. An unknown channel: + whatever the catalog in use needs.""" + if self.catalog_source == "geil": + return False + candidates = self._channel_candidates(channel_id) + if not candidates: + return self.needs_token() + return not all(_is_vavoo_index_url(c.get("url")) + for c in candidates) + def resolve_own(self, channel_id, slot, force=False): """channel_id's stream address with `slot`'s own token, for a recording - never through the shared resolve cache (the player @@ -1618,15 +1665,7 @@ def resolve_own(self, channel_id, slot, force=False): state (a grouped channel: the source the group plays from first, then the others, in resolve_group_with_retry()'s order). geil.to channels need no token at all.""" - if not channel_id: - return None - if channel_id.startswith(GROUP_ID_PREFIX): - country, key = parse_group_id(channel_id) - members = self._group_members(country, key) if key else [] - candidates = self._ordered_group_members(channel_id, members) - else: - channel = self.channels_by_id.get(channel_id) - candidates = [channel] if channel else [] + candidates = self._channel_candidates(channel_id) if not candidates: return None if self.catalog_source == "geil": @@ -1800,15 +1839,20 @@ def _install_catalog(self, channels, source, fallback=None): which the indexes' users rely on (country_counts() even goes by the identity of channels_by_country). fallback: the source the setting is pinned to, when this is another source's list lent - meanwhile (_lend_catalog()).""" + meanwhile (_lend_catalog()). token_required: a Vavoo list with + an address that is not one of vavoo.to's channel index.""" by_id = {} by_country = {} groups = {} countries = set() + needs_token = False # (a background thread: it gives way while a stream plays) breather = _Breather() for channel in channels: breather.tick() + if not needs_token and source != "geil" and \ + not _is_vavoo_index_url(channel.get("url")): + needs_token = True channel_id = channel.get("id") if channel_id: by_id[channel_id] = channel @@ -1823,6 +1867,9 @@ def _install_catalog(self, channels, source, fallback=None): if country and country != "default": countries.add(country) self.catalog_source = source + # (an empty Vavoo list: its API's, as before - a token is asked) + self.token_required = source != "geil" and ( + needs_token or not channels) self.catalog_fallback = fallback self.all_filtered_items = channels self.channels_by_id = by_id @@ -3431,11 +3478,11 @@ def do_GET(self): channels_count = len( p.all_filtered_items) if initialized else 0 - # When geil.to is the active catalog source, no - # token is ever fetched (it needs none) - requiring - # token_valid here too would always report - # "unhealthy" even though everything is working. - token_required = p.catalog_source != "geil" + # When geil.to (or vavoo.to's channel index) is the + # catalog in use, no token is needed - requiring + # token_valid here too would report "unhealthy" + # even though everything is working. + token_required = p.needs_token() proxy_status = { "status": "healthy" if initialized and ( token_valid or not token_required) else "unhealthy", diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_record.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_record.py index 75ae7cfb..727c4ac3 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_record.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_record.py @@ -584,11 +584,6 @@ def file_entry(file_id): return _files.get(file_id) -def unregister_file(file_id): - with _files_lock: - _files.pop(file_id, None) - - def unregister_path(path): path = _native(path) with _files_lock: diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_store.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_store.py index 90401b0f..edd38ff3 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_store.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/vavoo_store.py @@ -1174,10 +1174,6 @@ def tile_hue(name): return (hue_for(name) + step // 2) // step * step % 360 -def color_for(name): - return hsv_to_rgb(hue_for(name), 0.55, 0.62) - - # ------------------------------------------------------------------ search _SEARCH_SEPARATORS = re.compile(u"[\\W_]+", re.U) From c7c4dada28f94f717bf56220d1a468ee99bb43f6 Mon Sep 17 00:00:00 2001 From: pQu4k3r Date: Tue, 1 Dec 2026 13:09:53 +0000 Subject: [PATCH 3/3] 1.93: Vavoo/Kool channels again, no needless token, EPG database weekly Version 1.93 in __init__, CONTROL/control, installer.sh (with its changelog), the .bb and the README badge. In this version (develop since 1.92): - "Vavoo/Kool only" has channels again: Vavoo's catalog API answers HTTP 500 to everyone, so the proxy loads vavoo.to's own channel index (about 10 000 channels, 17 countries) and plays it with no token. - A token is asked and renewed only while the list in use needs one (not Geil's, not the index's); recordings likewise. - The curated EPG channel database is regenerated weekly on GitHub's runners again, and the plugin reads it from this repository. - Code nothing called removed. --- CONTROL/control | 2 +- README.md | 2 +- enigma2-plugin-extensions-vavoo.bb | 6 +++--- installer.sh | 19 ++++++++----------- .../Plugins/Extensions/vavoo/__init__.py | 2 +- .../python/Plugins/Extensions/vavoo/readme.md | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index afae91e0..a82f96f9 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,5 +1,5 @@ Package: enigma2-plugin-extensions-vavoo -Version: 1.92 +Version: 1.93 Section: misc Priority: optional Architecture: all diff --git a/README.md b/README.md index cd151988..321bf737 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- Version + Version diff --git a/enigma2-plugin-extensions-vavoo.bb b/enigma2-plugin-extensions-vavoo.bb index 6d9845be..109b0b8b 100644 --- a/enigma2-plugin-extensions-vavoo.bb +++ b/enigma2-plugin-extensions-vavoo.bb @@ -16,9 +16,9 @@ inherit allarch gitpkgv python3-compileall # CONTROL/control's Version:, and installer.sh's version= - none of # these are auto-synced (see CLAUDE.md), and this file previously # stayed at the placeholder "1.0" indefinitely. -PV = "1.92+git${SRCPV}" -PKGV = "1.92+git${GITPKGV}" -VER = "1.92" +PV = "1.93+git${SRCPV}" +PKGV = "1.93+git${GITPKGV}" +VER = "1.93" PR = "r0" SRC_URI = "git://github.com/OwnerPlugins/vavoo.git;protocol=https;branch=main" diff --git a/installer.sh b/installer.sh index 18858d1e..e50832ba 100644 --- a/installer.sh +++ b/installer.sh @@ -4,17 +4,14 @@ # Log: /tmp/vavoo_install.log (copia anche in /home/root/ a fine run) # ===================================================================== -version='1.92' -changelog="- Exported bouquets: every source of a channel (.b, .c, .d) as its own - channel; every Vavoo bouquet named Vavoo, a star and the country, as - the favourites one -- Favourites by country: a title per country in the Favourites list - (MENU - Move this country), and the favourites as one bouquet with a - title per country, kept the same as the list -- The scheduled bouquet update no longer hangs until a reboot -- Smoother playback: the plugin's background work gives way while a - channel plays -- Python 2 fixes (bouquets, EPG files with accents)" +version='1.93' +changelog="- Vavoo/Kool only has channels again: Vavoo's catalog answers an error + to everyone, so the plugin takes vavoo.to's own channel list (about + 10 000 channels, 17 countries) - played with no token at all +- No token asked for nothing: only while the list in use needs one +- The EPG channel database is updated every week again and read from + this plugin's own repository (more channels with a guide) +- Old code nothing used removed" LOGFILE=/tmp/vavoo_install.log diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py index f51d333a..306c8d37 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/__init__.py @@ -5,7 +5,7 @@ __email__ = "ekekaz@gmail.com" __copyright__ = 'Copyright (c) 2024 Lululla' __license__ = "CC BY-NC-SA 4.0" -__version__ = "1.92" +__version__ = "1.93" from Components.Language import language from Tools.Directories import resolveFilename, SCOPE_PLUGINS diff --git a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md index cd151988..321bf737 100644 --- a/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md +++ b/usr/lib/enigma2/python/Plugins/Extensions/vavoo/readme.md @@ -2,7 +2,7 @@

- Version + Version