Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,16 @@ async function load() {
"tt0258000",
];

// Create the folder if it doesn't exist
const folderPath = "./data/imdb";
const imdbFolderExists = await fs
.stat(folderPath)
.then(() => true)
.catch(() => false);
if (!imdbFolderExists) await fs.mkdir(folderPath);

for (const id of ids) {
const path = `./data/imdb/${id}.html`;
const path = `${folderPath}/${id}.html`;
const exists = await fs
.stat(path)
.then(() => true)
Expand Down Expand Up @@ -762,7 +770,7 @@ async function load() {
const year = parseInt(
$("title")
.text()
.match(/\((\d+)\)/)?.[1] || "0",
.match(/\((\d+)\)/)?.[1] || "0"
);
const title = $("[data-testid=subtitle]").text().trim();
const summary = $("[data-testid=sub-section-summaries] li:first-child")
Expand All @@ -783,7 +791,7 @@ async function load() {
Key: "posters/" + id + ".jpg",
ContentType: "image/jpeg",
Body: await fetch(poster).then((res) => res.arrayBuffer() as any),
}),
})
);

await vector.remove({
Expand Down Expand Up @@ -830,7 +838,7 @@ async function load() {
year,
}),
},
}),
})
);
console.log("Finished", ++index);
});
Expand Down