/** * Resolve one URL against the real browser and print the Post as JSON. * * npm run resolve -- 'https://www.tiktok.com/@user/video/123' * * This is the fastest way to find out whether a platform still works, and * the first thing to reach for when one stops. */ import { shutdown } from '../src/browser/pool.ts'; import { originalUrlFor, platformForUrl } from '../src/platforms/index.ts'; import { resolvePost } from '../src/resolve.ts'; const input = process.argv[2]; if (!input) { console.error('usage: npm run resolve -- '); process.exit(2); } const spec = platformForUrl(input); if (!spec) { console.error(`No adapter handles ${input}`); process.exit(2); } const parsed = new URL(input); const pathRest = parsed.pathname.replace(/^\/+/, ''); const originalUrl = originalUrlFor(spec, pathRest, parsed.search); try { const post = await resolvePost(spec, originalUrl, pathRest); console.log(JSON.stringify(post, null, 2)); } catch (error) { console.error(error instanceof Error ? error.message : error); process.exitCode = 1; } finally { await shutdown(); }