55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
// 2025-11-16-rm-fake-sourceVideo.ts
|
|
|
|
import PocketBase from 'pocketbase';
|
|
import { readFileSync } from 'node:fs';
|
|
import { basename, join } from 'node:path';
|
|
import spawn from 'nano-spawn';
|
|
import { tmpdir } from 'node:os';
|
|
import mime from 'mime';
|
|
|
|
const pb = new PocketBase(process.env.POCKETBASE_URL || 'http://127.0.0.1:8090');
|
|
if (!process.env.POCKETBASE_USERNAME) throw new Error('POCKETBASE_USERNAME missing');
|
|
if (!process.env.POCKETBASE_PASSWORD) throw new Error('POCKETBASE_PASSWORD missing');
|
|
|
|
interface ManifestItem {
|
|
thumbnail_url: string;
|
|
thumbnail_key: string;
|
|
tmp_file: string;
|
|
vod_id: string;
|
|
}
|
|
|
|
type Manifest = ManifestItem[];
|
|
|
|
interface Vod {
|
|
id: string;
|
|
thumbnail: string;
|
|
streamDate: string;
|
|
}
|
|
|
|
const vodsCollectionName = 'pbc_144770472';
|
|
// pbc_144770472 is the vods collection
|
|
// cv6m31vj98gmtsx is a sample vod id
|
|
|
|
|
|
|
|
async function main() {
|
|
console.log('Authenticating with PocketBase...');
|
|
await pb
|
|
.collection("_superusers")
|
|
.authWithPassword(process.env.POCKETBASE_USERNAME!, process.env.POCKETBASE_PASSWORD!);
|
|
|
|
const vods = await pb.collection('vods').getFullList({ filter: 'sourceVideo ~ "content/"' });
|
|
console.log(`${vods.length} vods.`);
|
|
|
|
for (const [i, vod] of vods.entries()) {
|
|
console.log("processing vod " + i + "/" + vods.length + " " + vod.id);
|
|
await pb.collection('vods').update(vod.id, { sourceVideo: '' });
|
|
}
|
|
|
|
console.log("All done.");
|
|
|
|
|
|
|
|
}
|
|
|
|
main() |