jbilcke-hf HF staff commited on
Commit
21c1773
1 Parent(s): deb99bf
Files changed (3) hide show
  1. package-lock.json +90 -0
  2. package.json +2 -0
  3. src/updatePlaylists.mts +11 -10
package-lock.json CHANGED
@@ -16,6 +16,8 @@
16
  "@types/uuid": "^9.0.2",
17
  "fluent-ffmpeg": "^2.1.2",
18
  "fs-extra": "^11.1.1",
 
 
19
  "node-fetch": "^3.3.1",
20
  "node-media-server": "^2.6.2",
21
  "puppeteer": "^20.7.4",
@@ -292,6 +294,15 @@
292
  "@types/send": "*"
293
  }
294
  },
 
 
 
 
 
 
 
 
 
295
  "node_modules/@types/http-errors": {
296
  "version": "2.0.1",
297
  "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.1.tgz",
@@ -302,6 +313,11 @@
302
  "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
303
  "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
304
  },
 
 
 
 
 
305
  "node_modules/@types/node": {
306
  "version": "20.4.1",
307
  "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
@@ -471,6 +487,11 @@
471
  "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz",
472
  "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw=="
473
  },
 
 
 
 
 
474
  "node_modules/base64-js": {
475
  "version": "1.5.1",
476
  "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -526,6 +547,14 @@
526
  "npm": "1.2.8000 || >= 1.4.16"
527
  }
528
  },
 
 
 
 
 
 
 
 
529
  "node_modules/buffer": {
530
  "version": "5.7.1",
531
  "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
@@ -1137,6 +1166,11 @@
1137
  "node": ">=14.14"
1138
  }
1139
  },
 
 
 
 
 
1140
  "node_modules/function-bind": {
1141
  "version": "1.1.1",
1142
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -1250,6 +1284,42 @@
1250
  "node": ">= 4.0.0"
1251
  }
1252
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1253
  "node_modules/graceful-fs": {
1254
  "version": "4.2.11",
1255
  "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@@ -1422,6 +1492,15 @@
1422
  "url": "https://github.com/sponsors/sindresorhus"
1423
  }
1424
  },
 
 
 
 
 
 
 
 
 
1425
  "node_modules/inherits": {
1426
  "version": "2.0.4",
1427
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -1594,6 +1673,17 @@
1594
  "node": ">= 0.6"
1595
  }
1596
  },
 
 
 
 
 
 
 
 
 
 
 
1597
  "node_modules/minimist": {
1598
  "version": "1.2.8",
1599
  "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
 
16
  "@types/uuid": "^9.0.2",
17
  "fluent-ffmpeg": "^2.1.2",
18
  "fs-extra": "^11.1.1",
19
+ "glob": "^8.1.0",
20
+ "glob-promise": "^6.0.3",
21
  "node-fetch": "^3.3.1",
22
  "node-media-server": "^2.6.2",
23
  "puppeteer": "^20.7.4",
 
294
  "@types/send": "*"
295
  }
296
  },
297
+ "node_modules/@types/glob": {
298
+ "version": "8.1.0",
299
+ "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz",
300
+ "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==",
301
+ "dependencies": {
302
+ "@types/minimatch": "^5.1.2",
303
+ "@types/node": "*"
304
+ }
305
+ },
306
  "node_modules/@types/http-errors": {
307
  "version": "2.0.1",
308
  "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.1.tgz",
 
313
  "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
314
  "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw=="
315
  },
316
+ "node_modules/@types/minimatch": {
317
+ "version": "5.1.2",
318
+ "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz",
319
+ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA=="
320
+ },
321
  "node_modules/@types/node": {
322
  "version": "20.4.1",
323
  "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
 
487
  "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.4.tgz",
488
  "integrity": "sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw=="
489
  },
490
+ "node_modules/balanced-match": {
491
+ "version": "1.0.2",
492
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
493
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
494
+ },
495
  "node_modules/base64-js": {
496
  "version": "1.5.1",
497
  "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
 
547
  "npm": "1.2.8000 || >= 1.4.16"
548
  }
549
  },
550
+ "node_modules/brace-expansion": {
551
+ "version": "2.0.1",
552
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
553
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
554
+ "dependencies": {
555
+ "balanced-match": "^1.0.0"
556
+ }
557
+ },
558
  "node_modules/buffer": {
559
  "version": "5.7.1",
560
  "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
 
1166
  "node": ">=14.14"
1167
  }
1168
  },
1169
+ "node_modules/fs.realpath": {
1170
+ "version": "1.0.0",
1171
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
1172
+ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
1173
+ },
1174
  "node_modules/function-bind": {
1175
  "version": "1.1.1",
1176
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
 
1284
  "node": ">= 4.0.0"
1285
  }
1286
  },
1287
+ "node_modules/glob": {
1288
+ "version": "8.1.0",
1289
+ "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz",
1290
+ "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==",
1291
+ "dependencies": {
1292
+ "fs.realpath": "^1.0.0",
1293
+ "inflight": "^1.0.4",
1294
+ "inherits": "2",
1295
+ "minimatch": "^5.0.1",
1296
+ "once": "^1.3.0"
1297
+ },
1298
+ "engines": {
1299
+ "node": ">=12"
1300
+ },
1301
+ "funding": {
1302
+ "url": "https://github.com/sponsors/isaacs"
1303
+ }
1304
+ },
1305
+ "node_modules/glob-promise": {
1306
+ "version": "6.0.3",
1307
+ "resolved": "https://registry.npmjs.org/glob-promise/-/glob-promise-6.0.3.tgz",
1308
+ "integrity": "sha512-m+kxywR5j/2Z2V9zvHKfwwL5Gp7gIFEBX+deTB9w2lJB+wSuw9kcS43VfvTAMk8TXL5JCl/cCjsR+tgNVspGyA==",
1309
+ "dependencies": {
1310
+ "@types/glob": "^8.0.0"
1311
+ },
1312
+ "engines": {
1313
+ "node": ">=16"
1314
+ },
1315
+ "funding": {
1316
+ "type": "individual",
1317
+ "url": "https://github.com/sponsors/ahmadnassri"
1318
+ },
1319
+ "peerDependencies": {
1320
+ "glob": "^8.0.3"
1321
+ }
1322
+ },
1323
  "node_modules/graceful-fs": {
1324
  "version": "4.2.11",
1325
  "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
 
1492
  "url": "https://github.com/sponsors/sindresorhus"
1493
  }
1494
  },
1495
+ "node_modules/inflight": {
1496
+ "version": "1.0.6",
1497
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
1498
+ "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
1499
+ "dependencies": {
1500
+ "once": "^1.3.0",
1501
+ "wrappy": "1"
1502
+ }
1503
+ },
1504
  "node_modules/inherits": {
1505
  "version": "2.0.4",
1506
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
 
1673
  "node": ">= 0.6"
1674
  }
1675
  },
1676
+ "node_modules/minimatch": {
1677
+ "version": "5.1.6",
1678
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
1679
+ "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
1680
+ "dependencies": {
1681
+ "brace-expansion": "^2.0.1"
1682
+ },
1683
+ "engines": {
1684
+ "node": ">=10"
1685
+ }
1686
+ },
1687
  "node_modules/minimist": {
1688
  "version": "1.2.8",
1689
  "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
package.json CHANGED
@@ -20,6 +20,8 @@
20
  "@types/uuid": "^9.0.2",
21
  "fluent-ffmpeg": "^2.1.2",
22
  "fs-extra": "^11.1.1",
 
 
23
  "node-fetch": "^3.3.1",
24
  "node-media-server": "^2.6.2",
25
  "puppeteer": "^20.7.4",
 
20
  "@types/uuid": "^9.0.2",
21
  "fluent-ffmpeg": "^2.1.2",
22
  "fs-extra": "^11.1.1",
23
+ "glob": "^8.1.0",
24
+ "glob-promise": "^6.0.3",
25
  "node-fetch": "^3.3.1",
26
  "node-media-server": "^2.6.2",
27
  "puppeteer": "^20.7.4",
src/updatePlaylists.mts CHANGED
@@ -1,5 +1,6 @@
1
  import fs from "fs"
2
  import path from "path"
 
3
 
4
  import { Database } from "./types.mts"
5
 
@@ -58,16 +59,16 @@ export const updatePlaylists = async (db: Database) => {
58
 
59
  // Read files from the sequence
60
  for (const shot of sequence.shots) {
61
- const shotId = shot.shotId;
62
- const mp4FileName = `${shotId}.mp4`
63
- const shotFilePath = path.join(directoryPath, mp4FileName)
64
-
65
- // Check if file exists
66
- if (fs.existsSync(shotFilePath)) {
67
- // Add the file path to the categories
68
- for (const tag of sequence.tags) {
69
- categoryToFilePaths[tag].push(shotFilePath)
70
- }
71
  }
72
  }
73
  }
 
1
  import fs from "fs"
2
  import path from "path"
3
+ import { promise as glob } from "glob-promise"
4
 
5
  import { Database } from "./types.mts"
6
 
 
59
 
60
  // Read files from the sequence
61
  for (const shot of sequence.shots) {
62
+ const shotId = shot.shotId
63
+ const shotFileNamePattern = `*${shotId}*.mp4`
64
+ const shotFilePathPattern = path.join(directoryPath, shotFileNamePattern)
65
+
66
+ const files = await glob(shotFilePathPattern)
67
+ const shotFilePath = files[0] // Get the first matching file
68
+
69
+ // Add the file path to the categories
70
+ for (const tag of sequence.tags) {
71
+ categoryToFilePaths[tag].push(shotFilePath)
72
  }
73
  }
74
  }