Spaces:
Running
Running
fix scrapping
Browse files
src/routes/api/scrap-models/+server.ts
CHANGED
|
@@ -27,6 +27,16 @@ export async function POST({ request }) {
|
|
| 27 |
}
|
| 28 |
index++
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
const hasImages = model?.siblings?.filter((sibling: Record<string, string>) => sibling?.rfilename.endsWith(".png") || sibling?.rfilename.endsWith(".jpeg") || sibling?.rfilename.endsWith(".jpg"))
|
| 31 |
if (hasImages.length > 0) {
|
| 32 |
model.image = hasImages[1]?.rfilename ? `https://huggingface.co/${model.id}/resolve/main/${hasImages[1]?.rfilename}` : `https://huggingface.co/${model.id}/resolve/main/${hasImages[0]?.rfilename}`
|
|
@@ -49,15 +59,6 @@ export async function POST({ request }) {
|
|
| 49 |
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
| 50 |
}
|
| 51 |
}
|
| 52 |
-
const existing_model = await prisma.model.findUnique({
|
| 53 |
-
where: {
|
| 54 |
-
id: model.id
|
| 55 |
-
}
|
| 56 |
-
})
|
| 57 |
-
|
| 58 |
-
if (existing_model) {
|
| 59 |
-
continue;
|
| 60 |
-
}
|
| 61 |
|
| 62 |
await prisma.model.create({
|
| 63 |
data: {
|
|
|
|
| 27 |
}
|
| 28 |
index++
|
| 29 |
|
| 30 |
+
const existing_model = await prisma.model.findUnique({
|
| 31 |
+
where: {
|
| 32 |
+
id: model.id
|
| 33 |
+
}
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
if (existing_model) {
|
| 37 |
+
continue;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
const hasImages = model?.siblings?.filter((sibling: Record<string, string>) => sibling?.rfilename.endsWith(".png") || sibling?.rfilename.endsWith(".jpeg") || sibling?.rfilename.endsWith(".jpg"))
|
| 41 |
if (hasImages.length > 0) {
|
| 42 |
model.image = hasImages[1]?.rfilename ? `https://huggingface.co/${model.id}/resolve/main/${hasImages[1]?.rfilename}` : `https://huggingface.co/${model.id}/resolve/main/${hasImages[0]?.rfilename}`
|
|
|
|
| 59 |
else model.image = `https://huggingface.co/${model.id}/resolve/main/${image.replace("./", "")}`
|
| 60 |
}
|
| 61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
await prisma.model.create({
|
| 64 |
data: {
|