799967501@qq.com

添加华为云查询文件是否存在接口

... ... @@ -237,6 +237,11 @@
"resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz",
"integrity": "sha1-sNBClG2ylTu50pKQCmy19tASIDE="
},
"date-format": {
"version": "3.0.0",
"resolved": "https://registry.npm.taobao.org/date-format/download/date-format-3.0.0.tgz",
"integrity": "sha1-64eANlx9KxURB4+0keZHl4DzrZU="
},
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
... ... @@ -311,6 +316,15 @@
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
},
"esdk-obs-nodejs": {
"version": "3.20.11",
"resolved": "https://registry.npm.taobao.org/esdk-obs-nodejs/download/esdk-obs-nodejs-3.20.11.tgz",
"integrity": "sha1-/bMuzu3qoT+xLgmCcgg8yM6MIsE=",
"requires": {
"log4js": "^6.3.0",
"xml2js": "^0.4.23"
}
},
"etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
... ... @@ -367,6 +381,11 @@
"unpipe": "~1.0.0"
}
},
"flatted": {
"version": "2.0.2",
"resolved": "https://registry.npm.taobao.org/flatted/download/flatted-2.0.2.tgz",
"integrity": "sha1-RXWyHivO50NKqb5mL0t7X5wrUTg="
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
... ... @@ -395,6 +414,16 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffs-extra%2Fdownload%2Ffs-extra-8.1.0.tgz",
"integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
... ... @@ -418,6 +447,11 @@
"path-is-absolute": "^1.0.0"
}
},
"graceful-fs": {
"version": "4.2.4",
"resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.4.tgz",
"integrity": "sha1-Ila94U02MpWMRl68ltxGfKB6Kfs="
},
"graceful-readlink": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
... ... @@ -542,6 +576,14 @@
"with": "~4.0.0"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npm.taobao.org/jsonfile/download/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jstransformer": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz",
... ... @@ -564,6 +606,33 @@
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
"integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4="
},
"log4js": {
"version": "6.3.0",
"resolved": "https://registry.npm.taobao.org/log4js/download/log4js-6.3.0.tgz",
"integrity": "sha1-EN+vu0NDUaPjAnegC5h5RG9xW8s=",
"requires": {
"date-format": "^3.0.0",
"debug": "^4.1.1",
"flatted": "^2.0.1",
"rfdc": "^1.1.4",
"streamroller": "^2.2.4"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npm.taobao.org/debug/download/debug-4.3.1.tgz?cache=0&sync_timestamp=1607566551397&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.3.1.tgz",
"integrity": "sha1-8NIpxQXgxtjEmsVT0bE9wYP2su4=",
"requires": {
"ms": "2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&sync_timestamp=1607433856030&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz",
"integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk="
}
}
},
"longest": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
... ... @@ -785,6 +854,11 @@
"path-parse": "^1.0.6"
}
},
"rfdc": {
"version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/rfdc/download/rfdc-1.2.0.tgz",
"integrity": "sha1-npiUJY9I8oS0PDFDxoBwpPNzuUk="
},
"right-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
... ... @@ -803,6 +877,11 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npm.taobao.org/sax/download/sax-1.2.4.tgz",
"integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
},
"send": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
... ... @@ -862,6 +941,36 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
"integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
},
"streamroller": {
"version": "2.2.4",
"resolved": "https://registry.npm.taobao.org/streamroller/download/streamroller-2.2.4.tgz",
"integrity": "sha1-wZjO1C25QIamGTYIGHzoCl8rDlM=",
"requires": {
"date-format": "^2.1.0",
"debug": "^4.1.1",
"fs-extra": "^8.1.0"
},
"dependencies": {
"date-format": {
"version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/date-format/download/date-format-2.1.0.tgz",
"integrity": "sha1-MdW16iEc9f12TNOLr50DPffhJc8="
},
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npm.taobao.org/debug/download/debug-4.3.1.tgz?cache=0&sync_timestamp=1607566551397&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdebug%2Fdownload%2Fdebug-4.3.1.tgz",
"integrity": "sha1-8NIpxQXgxtjEmsVT0bE9wYP2su4=",
"requires": {
"ms": "2.1.2"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz?cache=0&sync_timestamp=1607433856030&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fms%2Fdownload%2Fms-2.1.2.tgz",
"integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk="
}
}
},
"string.prototype.trimleft": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz",
... ... @@ -954,6 +1063,11 @@
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
"optional": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npm.taobao.org/universalify/download/universalify-0.1.2.tgz?cache=0&sync_timestamp=1603179971960&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funiversalify%2Fdownload%2Funiversalify-0.1.2.tgz",
"integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
... ... @@ -1017,6 +1131,20 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"xml2js": {
"version": "0.4.23",
"resolved": "https://registry.npm.taobao.org/xml2js/download/xml2js-0.4.23.tgz?cache=0&sync_timestamp=1576776888003&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxml2js%2Fdownload%2Fxml2js-0.4.23.tgz",
"integrity": "sha1-oMaVFnUkIesqx1juTUzPWIQ+rGY=",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
}
},
"xmlbuilder": {
"version": "11.0.1",
"resolved": "https://registry.npm.taobao.org/xmlbuilder/download/xmlbuilder-11.0.1.tgz",
"integrity": "sha1-vpuuHIoEbnazESdyY0fQrXACvrM="
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
... ...
... ... @@ -11,6 +11,7 @@
"child_process": "^1.0.2",
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"esdk-obs-nodejs": "^3.20.11",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
... ...
... ... @@ -3,6 +3,7 @@ var router = express.Router();
const { spawn, exec } = require('child_process');
const fs = require("fs");
var path = require('path')
var ObsClient = require('esdk-obs-nodejs');
const method = require("../config/method")
const config = require("../config/config")
... ... @@ -117,7 +118,7 @@ class MediaCreat {
// export DISPLAY=:7
// let url = `${path.resolve(__dirname, PROJECTWINCATALOG+"/web_capture_c")} -o=${ymdDir}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&recordMp4=${BACKMEDIACONFIG.recordMp4}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
// console.log("url", url)
let url = `${PROJECTWINCATALOG}/web_capture_c -o=${ymdDir}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&recordMp4=${BACKMEDIACONFIG.recordMp4}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}&language=zh-cn" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h}`
let url = `${PROJECTWINCATALOG}/web_capture_c -o=${ymdDir}/${id}.mp4 -u="${BACKMEDIACONFIG.url}?classId=${id}&recordMp4=${BACKMEDIACONFIG.recordMp4}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}&language=zh-cn" -d=${BACKMEDIACONFIG.d} -s=${BACKMEDIACONFIG.s} -fa=${BACKMEDIACONFIG.fa} -k=${BACKMEDIACONFIG.k} -w=${BACKMEDIACONFIG.w} -h=${BACKMEDIACONFIG.h} -vb=999999999999`
exec(url, { maxBuffer: 1073741824 }, (err, stdout, stderr) => {
if (err != null) {
this.wrieLog(" 错误" + id + ":" + err)
... ... @@ -251,44 +252,73 @@ router.post('/recording', async function (req, res, next) {
// 判断该视频文件是否存在
router.post('/fileExists', async function (req, res, next) {
let fileConfig = new MediaCreat().getConfigFileJson()
const { PROJECTCATALOG } = JSON.parse(fileConfig)
const body = req.body
if(!body.siteId) {
res.send({ code: 2,message:"机构编码无效" });
if (!body.siteId) {
res.send({code: 2, message: "机构编码无效"});
return
}
if(!body.classId) {
res.send({ code: 3,message:"课堂号无效" });
if (!body.classId) {
res.send({code: 3, message: "课堂号无效"});
return
}
let timeDir = PROJECTCATALOG + "/media/" + body.siteId
if (!fs.existsSync(timeDir)) {
res.send({ code: 4,message:"目录未生成" });
return
}
const timeFiles = fs.readdirSync(timeDir)
let classIdStr = `${body.classId}.mp4`
let isFile = false
let fileTime = ""
for(let i=0;i<timeFiles.length;i++){
let classDir = `${timeDir}/${timeFiles[i]}`
const classFiles = fs.readdirSync(classDir)
if(classFiles.indexOf(classIdStr) > -1){
fileTime = timeFiles[i]
isFile = true
break
}
}
if(isFile){
let classUrl = `https://xdymp4.xuedianyun.com/oss/${body.siteId}/${fileTime}/${body.classId}.mp4`
res.send({ code: 0,message:"文件已生成",classUrl });
}else {
// if(!body.classStartTime) {
// res.send({ code: 4,message:"时间不存在" });
// return
// }
// 创建ObsClient实例
var obsClient = new ObsClient({
access_key_id: 'FY27OD11ZJVC385AOTW9',
secret_access_key: 'ZqnfRjaseCtuRbE79GvqkPiYUdT83ZbB0oU7fBo3',
server: 'obs.cn-north-4.myhuaweicloud.com'
});
let isVideo = false
let url = ""
let Prefix = ""
if (body.classStartTime) {
Prefix = `oss/${body.siteId}/${body.classStartTime}/${body.classId}.mp4`
obsClient.listObjects({
Bucket: 'xdymp4',
Prefix: Prefix,
// MaxKeys:1
}, (err, result) => {
if (err) {
console.error('Error-->' + err);
} else {
if (result.CommonMsg.Status == 200) {
let content = result.InterfaceResult.Contents
if (content && content.length) {
if (content[0].Key) {
isVideo = true
url = content[0].Key
}
}
// for(let i=0;i<result.InterfaceResult.Contents.length;i++){
// let item = result.InterfaceResult.Contents[i]
// if(item.Key && item.Key.indexOf(body.classId) > -1){
// isVideo = true
// url = item.Key
// break
// }
// }
}
}
if (!isVideo) {
let classUrl = `https://pclive.xuedianyun.com/pcBase/pclive2/release/index.html?portalIP=saas.xuedianyun.com&portalPort=80&classId=${body.classId}&channels=2&playRecord=1#/`
res.send({code: 1, message: "文件未生成", classUrl});
} else {
let classUrl = `https://xdymp4.xuedianyun.com/${url}`
res.send({code: 0, message: "文件已生成", classUrl});
}
// 关闭obsClient
obsClient.close();
});
}else{
let classUrl = `https://pclive.xuedianyun.com/pcBase/pclive2/release/index.html?portalIP=saas.xuedianyun.com&portalPort=80&classId=${body.classId}&channels=2&playRecord=1#/`
res.send({ code: 1,message:"文件未生成",classUrl });
res.send({code: 1, message: "文件未生成", classUrl});
}
})
module.exports = router;
... ...