import { PureframeClient } from "@pureframeai/sdk"
import * as fs from "fs"
const client = new PureframeClient({ token: "pf_..." })
// Create a collection
const collection = await client.collections.createCollection({ name: "Product demos" })
const collectionId = collection.data.id
// Upload a video
const job = await client.upload.uploadVideo({
collection_id: collectionId,
file: fs.createReadStream("demo.mp4"),
})
const jobId = job.data.job_id
// Poll until done
let done = false
while (!done) {
const status = await client.jobs.getJob({ job_id: jobId })
if (status.data.status === "done") done = true
else await new Promise(r => setTimeout(r, 5000))
}
// Search
const results = await client.search.search({
query: "pricing objection",
collection_id: collectionId,
})
for (const video of results.data) {
for (const seg of video.segments) {
console.log(`${video.filename} @ ${seg.timestamp_start}s — score: ${seg.score}`)
}
}