---
type: "Source File"
title: "\"\"\"Retry single video: BBC Bartlett\"\"\""
description: "\"\"\"Retry single video: BBC Bartlett\"\"\" import sys, os, json, requests, re, sqlite3 sys.path.insert(0, '/home/ben/infra/copecheck-uk') from dotenv import load_dotenv load_dotenv('/home/ben/infra/copecheck-uk/.env') from."
resource: "https://uk.copecheck.com"
tags: ["copecheck", "uk", "source-file", "py"]
timestamp: "2026-05-10T13:29:00Z"
site: "uk"
source_path: "copecheck-uk/rescore_single.py"
---

# """Retry single video: BBC Bartlett"""

Source path: `copecheck-uk/rescore_single.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-05-10T13:29:00Z`

```py
"""Retry single video: BBC Bartlett"""
import sys, os, json, requests, re, sqlite3
sys.path.insert(0, '/home/ben/infra/copecheck-uk')
from dotenv import load_dotenv
load_dotenv('/home/ben/infra/copecheck-uk/.env')
from youtube_scorer import COPE_SYSTEM_PROMPT

[redacted secret-like line]
WHISPER_PROXY = 'http://100.126.77.97:5050'
DB_PATH = '/home/ben/infra/copecheck-uk/data/copecheck_uk.db'

vid_id = 'XV_B96fAzKs'
title = 'Steven Bartlett sharing harmful health misinformation in Diary of CEO podcast | BBC News'
channel = 'BBC News'

# Get transcript
resp = requests.get(f'{WHISPER_PROXY}/whisper/{vid_id}', timeout=(10, 180))
data = resp.json()
text = ' '.join(s['text'].strip() for s in data['segments'])
print(f'Transcript: {len(text)} chars')

# Score with MiniMax
[redacted secret-like line]
payload = {
    'model': 'minimax-m2.7',
    'messages': [
        {'role': 'system', 'content': COPE_SYSTEM_PROMPT},
        {'role': 'user', 'content': f'VIDEO: "{title}" by {channel}\n\nTRANSCRIPT:\n{text[:80000]}'},
    ],
[redacted secret-like line]
    'temperature': 0.7,
}
resp2 = requests.post('https://api.minimax.io/v1/chat/completions', headers=headers, json=payload, timeout=120)
raw = resp2.json()['choices'][0]['message']['content']
raw = re.sub(r'<think>.*?</think>', '', raw, flags=re.DOTALL).strip()
if raw.startswith('```'):
    raw = re.sub(r'^```(?:json)?\n?', '', raw)
    raw = re.sub(r'\n?```$', '', raw)

print(f'Raw response length: {len(raw)}')
print(f'First 300 chars: {raw[:300]}')
print('---')

# Try to parse
try:
    result = json.loads(raw)
    score = float(result.get('cope_score') or 0)
    summary = str(result.get('summary', ''))
except:
    # Regex fallback
    m = re.search(r'"cope_score"\s*:\s*(\d+(?:\.\d+)?)', raw)
    if m:
        score = float(m.group(1))
        sm = re.search(r'"summary"\s*:\s*"((?:[^"\\]|\\.)*)"', raw)
        summary = sm.group(1) if sm else 'Regex extraction'
    else:
        print('FAILED to extract score')
        sys.exit(1)

print(f'Score: {score}')
print(f'Summary: {summary[:100]}')

# Update DB
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
c.execute('UPDATE youtube_videos SET cope_score = ?, cope_summary = ?, scored_at = CURRENT_TIMESTAMP WHERE video_id = ?',
          (score, summary, vid_id))
conn.commit()
conn.close()
print('DB updated!')
```
