---
type: "Source File"
title: "\"\"\"Seed YouTube videos using MiniMax instead of Gemini.\"\"\""
description: "\"\"\"Seed YouTube videos using MiniMax instead of Gemini.\"\"\" import os import sys import json import re import sqlite3 import requests from datetime import datetime sys.path.insert(0, os.path.dirname(__file__)) from."
resource: "https://uk.copecheck.com"
tags: ["copecheck", "uk", "source-file", "py"]
timestamp: "2026-04-27T11:18:57Z"
site: "uk"
source_path: "copecheck-uk/seed_yt_minimax.py"
---

# """Seed YouTube videos using MiniMax instead of Gemini."""

Source path: `copecheck-uk/seed_yt_minimax.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-04-27T11:18:57Z`

```py
"""Seed YouTube videos using MiniMax instead of Gemini."""
import os
import sys
import json
import re
import sqlite3
import requests
from datetime import datetime

sys.path.insert(0, os.path.dirname(__file__))
from dotenv import load_dotenv
load_dotenv()

from youtube_scorer import extract_video_id, get_transcript, get_video_info

[redacted secret-like line]
MINIMAX_URL = "https://api.minimax.io/v1/chat/completions"
DB_PATH = os.path.join(os.path.dirname(__file__), "data", "copecheck_uk.db")

VIDEOS = [
    "QUQsMZIAgls",  # Gary Stevenson
    "Ds3R8AckpXs",  # Owen Jones
    "Fn9A9o8HGjM",  # Tom Harwood
    "37HGgQWtIvU",  # Aaron Bastani
    "XV_B96fAzKs",  # Steven Bartlett
]

SYSTEM_PROMPT = """You are the UK Oracle of Obsolescence — a forensic analyst of British political and economic cope.

Score this YouTube video transcript for COPE content. Cope is defined as: deflection, scapegoating, denial of structural problems, magical thinking about solutions, or any rhetorical strategy that avoids confronting uncomfortable economic/political realities.

Analyse the transcript and return a JSON object with:
- cope_score: float 0-10 (0 = brutally honest, 10 = weapons-grade cope)
- summary: 2-3 sentence summary of the cope (or honesty) in this video. Sardonic, punchy tone.
- scapegoats: comma-separated list of who/what gets blamed
- cope_mechanisms: comma-separated list of specific cope techniques used
- key_quotes: list of 3-5 most cope-laden (or most honest) quotes from the transcript

Return ONLY valid JSON, no markdown formatting."""


def score_with_minimax(transcript, title, channel):
    """Score transcript using MiniMax M2.7."""
    user_prompt = f'VIDEO: "{title}" by {channel}\n\nTRANSCRIPT:\n{transcript[:15000]}'
    try:
        resp = requests.post(MINIMAX_URL, headers={
[redacted secret-like line]
            "Content-Type": "application/json"
        }, json={
            "model": "minimax-m2.7",
            "messages": [
                {"role": "system", "content": SYSTEM_PROMPT},
                {"role": "user", "content": user_prompt}
            ],
            "temperature": 0.7,
[redacted secret-like line]
        }, timeout=90)
        if resp.status_code != 200:
            print(f"  MiniMax error: {resp.status_code}")
            return None
        text = resp.json()["choices"][0]["message"]["content"]
        text = text.strip()
        # Strip MiniMax think tags
        think_match = re.search(r'</think>', text)
        if think_match:
            text = text[think_match.end():].strip()
        if text.startswith("```"):
            text = re.sub(r"^```(?:json)?\n?", "", text)
            text = re.sub(r"\n?```$", "", text)
        return json.loads(text)
    except Exception as e:
        print(f"  MiniMax scoring error: {e}")
        return None


def save_video(conn, video_id, info, transcript, result):
    """Save scored video to DB."""
    conn.execute("""
        INSERT OR REPLACE INTO youtube_videos
        (video_id, title, channel, url, transcript_length, cope_score,
         cope_summary, scapegoats, cope_mechanisms, key_quotes,
         submitted_by, status, scored_at)
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    """, (
        video_id, info["title"], info["channel"],
        f"https://www.youtube.com/watch?v={video_id}",
        len(transcript),
        result.get("cope_score", 0),
        result.get("summary", ""),
        result.get("scapegoats", ""),
        result.get("cope_mechanisms", ""),
        json.dumps(result.get("key_quotes", [])),
        "system", "scored", datetime.utcnow().isoformat()
    ))
    conn.commit()


if __name__ == "__main__":
    conn = sqlite3.connect(DB_PATH)
    # Ensure table exists
    conn.execute("""CREATE TABLE IF NOT EXISTS youtube_videos (
        video_id TEXT PRIMARY KEY,
        title TEXT, channel TEXT, url TEXT,
        transcript_length INTEGER, cope_score REAL,
        cope_summary TEXT, scapegoats TEXT,
        cope_mechanisms TEXT, key_quotes TEXT,
        submitted_by TEXT DEFAULT 'system',
        status TEXT DEFAULT 'pending',
        scored_at TEXT
    )""")
    conn.commit()

    for vid in VIDEOS:
        print(f"\n=== Scoring {vid} ===")
        info = get_video_info(vid)
        print(f"  Title: {info['title']}")
        print(f"  Channel: {info['channel']}")

        transcript = get_transcript(vid)
        if not transcript:
            print(f"  SKIP: no transcript")
            continue
        print(f"  Transcript: {len(transcript)} chars")

        result = score_with_minimax(transcript, info["title"], info["channel"])
        if not result:
            print(f"  SKIP: scoring failed")
            continue

        print(f"  Cope score: {result.get('cope_score')}")
        print(f"  Summary: {result.get('summary', '')[:100]}")
        save_video(conn, vid, info, transcript, result)
        print(f"  SAVED!")

    conn.close()
    print("\nDone!")
```
