Skip to content

Commit 7413515

Browse files
committed
use category cache
1 parent f7d850a commit 7413515

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
permissions: write-all
99

1010
env:
11-
# 是否重新生成 vod/xvod 的 category
12-
VOD_CATES: "1"
11+
# 是否重新生成 vod/xvod 的 category("0" | "1")
12+
VOD_CATES: "0"
1313

1414
jobs:
1515
build-and-deploy:

.vscode/launch.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
"args": [
1313
"vod.json",
1414
"xvod.json"
15-
]
15+
],
16+
"env": {
17+
"VOD_CATES": "0",
18+
}
1619
},
1720
{
1821
"type": "bun",

vod.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { writeFileSync } from 'fs'
22
import { join } from 'path'
33
import { getAvailableCategoryWithCfg } from "./vod_utils"
4+
import { req } from "utils"
45

56
const vods = <Iconfig[]>[
67
{
@@ -682,6 +683,29 @@ const file2 = join(process.cwd(), nsfwVodFile);
682683
console.error(error)
683684
}
684685
}
686+
} else {
687+
const __vod: Iconfig[] = JSON.parse(await req("https://d1y.github.io/kitty/vod.json"))
688+
const __xvod: Iconfig[] = JSON.parse(await req("https://d1y.github.io/kitty/xvod.json"))
689+
const ___vod = new Map(__vod.map(item => [item.id, item]))
690+
const ___xvod = new Map(__xvod.map(item => [item.id, item]))
691+
vods.forEach(item => {
692+
const cx = ___vod.get(item.id)
693+
if (!cx) return
694+
cx.extra ??= {}
695+
if (cx.extra!.category) {
696+
item.extra ??= {}
697+
item.extra.category = cx.extra.category
698+
}
699+
})
700+
nsfwVods.forEach(item => {
701+
const cx = ___xvod.get(item.id)
702+
if (!cx) return
703+
cx.extra ??= {}
704+
if (cx.extra!.category) {
705+
item.extra ??= {}
706+
item.extra.category = cx.extra.category
707+
}
708+
})
685709
}
686710
writeFileSync(file1, JSON.stringify(vods, null, 2))
687711
writeFileSync(file2, JSON.stringify(nsfwVods, null, 2))

0 commit comments

Comments
 (0)