正在显示
1 个修改的文件
包含
37 行增加
和
0 行删除
@@ -249,5 +249,42 @@ router.post('/recording', async function (req, res, next) { | @@ -249,5 +249,42 @@ router.post('/recording', async function (req, res, next) { | ||
249 | 249 | ||
250 | }) | 250 | }) |
251 | 251 | ||
252 | +// 判断该视频文件是否存在 | ||
253 | +router.post('/fileExists', async function (req, res, next) { | ||
254 | + let fileConfig = new MediaCreat().getConfigFileJson() | ||
255 | + const { PROJECTCATALOG } = JSON.parse(fileConfig) | ||
256 | + const body = req.body | ||
257 | + if(!body.siteId) { | ||
258 | + res.send({ code: 2,message:"机构编码无效" }); | ||
259 | + return | ||
260 | + } | ||
261 | + if(!body.classId) { | ||
262 | + res.send({ code: 3,message:"课堂号无效" }); | ||
263 | + return | ||
264 | + } | ||
265 | + let timeDir = PROJECTCATALOG + "/media/" + body.siteId | ||
266 | + | ||
267 | + if (!fs.existsSync(timeDir)) { | ||
268 | + res.send({ code: 4,message:"目录未生成" }); | ||
269 | + return | ||
270 | + } | ||
271 | + const timeFiles = fs.readdirSync(timeDir) | ||
272 | + let classIdStr = `${body.classId}.mp4` | ||
273 | + let isFile = false | ||
274 | + for(let i=0;i<timeFiles.length;i++){ | ||
275 | + let classDir = `${timeDir}/${timeFiles[i]}` | ||
276 | + const classFiles = fs.readdirSync(classDir) | ||
277 | + if(classFiles.indexOf(classIdStr) > -1){ | ||
278 | + isFile = true | ||
279 | + break | ||
280 | + } | ||
281 | + } | ||
282 | + if(isFile){ | ||
283 | + res.send({ code: 0,message:"文件已生成" }); | ||
284 | + }else { | ||
285 | + res.send({ code: 1,message:"文件未生成" }); | ||
286 | + } | ||
287 | + | ||
288 | +}) | ||
252 | 289 | ||
253 | module.exports = router; | 290 | module.exports = router; |
-
请 注册 或 登录 后发表评论