This commit is contained in:
Nick Sweeting
2025-12-28 17:51:54 -08:00
parent 54f91c1339
commit f0aa19fa7d
157 changed files with 6774 additions and 5061 deletions

View File

@@ -225,6 +225,7 @@ async function main() {
let status = 'failed';
let output = null;
let error = '';
let extractedTitle = null;
try {
const result = await extractTitle(url);
@@ -232,7 +233,8 @@ async function main() {
if (result.success) {
status = 'succeeded';
output = result.output;
console.log(`Title extracted (${result.method}): ${result.title}`);
extractedTitle = result.title;
console.error(`Title extracted (${result.method}): ${result.title}`);
} else {
status = 'failed';
error = result.error;
@@ -248,13 +250,22 @@ async function main() {
console.error(`ERROR: ${error}`);
}
// Output clean JSONL (no RESULT_JSON= prefix)
const result = {
// Update snapshot title via JSONL
if (status === 'succeeded' && extractedTitle) {
console.log(JSON.stringify({
type: 'Snapshot',
id: snapshotId,
title: extractedTitle
}));
}
// Output ArchiveResult JSONL
const archiveResult = {
type: 'ArchiveResult',
status,
output_str: output || error || '',
output_str: extractedTitle || error || '',
};
console.log(JSON.stringify(result));
console.log(JSON.stringify(archiveResult));
process.exit(status === 'succeeded' ? 0 : 1);
}

View File

@@ -2,6 +2,7 @@
Integration tests for title plugin
Tests verify:
pass
1. Plugin script exists
2. Node.js is available
3. Title extraction works for real example.com
@@ -35,7 +36,7 @@ def test_extracts_title_from_example_com():
# Check node is available
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -56,6 +57,7 @@ def test_extracts_title_from_example_com():
for line in result.stdout.strip().split('\n'):
line = line.strip()
if line.startswith('{'):
pass
try:
record = json.loads(line)
if record.get('type') == 'ArchiveResult':
@@ -84,7 +86,7 @@ def test_falls_back_to_http_when_chrome_unavailable():
"""Test that title plugin falls back to HTTP when chrome unavailable."""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -107,6 +109,7 @@ def test_falls_back_to_http_when_chrome_unavailable():
for line in result.stdout.strip().split('\n'):
line = line.strip()
if line.startswith('{'):
pass
try:
record = json.loads(line)
if record.get('type') == 'ArchiveResult':
@@ -130,7 +133,7 @@ def test_config_timeout_honored():
"""Test that TIMEOUT config is respected."""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -157,7 +160,7 @@ def test_config_user_agent():
"""Test that USER_AGENT config is used."""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -183,6 +186,7 @@ def test_config_user_agent():
for line in result.stdout.strip().split('\n'):
line = line.strip()
if line.startswith('{'):
pass
try:
record = json.loads(line)
if record.get('type') == 'ArchiveResult':
@@ -199,7 +203,7 @@ def test_handles_https_urls():
"""Test that HTTPS URLs work correctly."""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -229,7 +233,7 @@ def test_handles_404_gracefully():
"""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
@@ -251,7 +255,7 @@ def test_handles_redirects():
"""Test that title plugin handles redirects correctly."""
if not shutil.which('node'):
pytest.skip("node not installed")
pass
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)