fp/services/pocketbase/utils/data_migrations/2025-11-16-rm-fake-sourceVideo.ts
CJ_Clippy 87b054e66f
Some checks failed
ci / test (push) Failing after 4m45s
fp/our CI/CD / build (push) Successful in 58s
restrict playback to logged in visitors
2025-11-19 17:46:35 -08:00

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()