INNER CODE UNIT · Python

build_sid_authorization

cwuom/NeriPlayer · tools_pub/ytmusic_api_probe.py:391

def build_sid_authorization(
    scheme: str,
    sid: str,
    origin: str,
    now_epoch_seconds: int,
    user_session_id: str = "",
) -> str:
    extra_values: list[str] = []
    if user_session_id:
        extra_values.append(user_session_id)
    hash_parts = [*extra_values, str(now_epoch_seconds), sid, origin]
    digest = hashlib.sha1(" ".join(hash_parts).encode("utf-8")).hexdigest()
    header_parts = [str(now_epoch_seconds), digest]
    if user_session_id:
        header_parts.append(f"u={user_session_id}")
    return f"{scheme} {'_'.join(header_parts)}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…