INNER CODE UNIT · Python

load_cookie_map

Mr-funny/hbg-classical-poem-silk-video · skill/classical-poem-silk-video/scripts/docker_gemini_i2v.py:12

def load_cookie_map(path: Path) -> dict[str, str]:
    data = json.loads(path.read_text(encoding="utf-8"))
    if isinstance(data, dict) and isinstance(data.get("cookieMap"), dict):
        data = data["cookieMap"]
    elif isinstance(data, list):
        data = {
            item.get("name"): item.get("value")
            for item in data
            if isinstance(item, dict) and item.get("name") and item.get("value")
        }
    if not isinstance(data, dict) or not data.get("__Secure-1PSID"):
        raise RuntimeError("Gemini cookie file is not authorized")
    return {str(key): str(value) for key, value in data.items() if value is not None}


async def main() -> int:
    image = Path(os.environ["POEM_I2V_IMAGE"])
    output = Path(os.environ["POEM_I2V_OUTPUT"])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…