- misc edits.
This commit is contained in:
doms9 2026-06-10 11:38:58 -04:00
parent 9b54e4a7af
commit 00000d9a7b
2 changed files with 10 additions and 8 deletions

View file

@ -1,6 +1,7 @@
import base64 import base64
import re import re
from functools import partial from functools import partial
from urllib.parse import urlsplit
from .utils import Cache, Time, get_logger, leagues, network from .utils import Cache, Time, get_logger, leagues, network
@ -41,9 +42,14 @@ async def process_event(channel_id: str, url_num: int) -> tuple[str | None, str
log.warning(f"URL {url_num}) No M3U8 found") log.warning(f"URL {url_num}) No M3U8 found")
return nones return nones
m3u8 = base64.b64decode(match[2]).decode("utf-8")
log.info(f"URL {url_num}) Captured M3U8") log.info(f"URL {url_num}) Captured M3U8")
return base64.b64decode(match[2]).decode("utf-8"), ref_url return (
m3u8.replace(urlsplit(m3u8).netloc, "kolis.phantemlis.top"),
ref_url,
)
async def get_events() -> list[dict[str, str]]: async def get_events() -> list[dict[str, str]]:
@ -95,11 +101,7 @@ async def get_events() -> list[dict[str, str]]:
events.append( events.append(
{ {
"sport": ( "sport": category,
"Soccer"
if category.lower() == "all soccer events"
else category
),
"event": name, "event": name,
"channel-id": channel_id, "channel-id": channel_id,
"timestamp": now.timestamp(), "timestamp": now.timestamp(),

View file

@ -7,7 +7,7 @@ from contextlib import asynccontextmanager
from functools import cache, partial from functools import cache, partial
from pathlib import Path from pathlib import Path
from typing import TypeVar from typing import TypeVar
from urllib.parse import urlparse from urllib.parse import urlsplit
import httpx import httpx
from playwright.async_api import ( from playwright.async_api import (
@ -134,7 +134,7 @@ class Network:
@staticmethod @staticmethod
def to_block(request: Request) -> bool: def to_block(request: Request) -> bool:
hostname = (urlparse(request.url).hostname or "").lower() hostname = (urlsplit(request.url).hostname or "").lower()
return any( return any(
hostname == domain or hostname.endswith(f".{domain}") hostname == domain or hostname.endswith(f".{domain}")