799967501@qq.com

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

@@ -237,6 +237,11 @@ @@ -237,6 +237,11 @@
237 "resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz", 237 "resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz",
238 "integrity": "sha1-sNBClG2ylTu50pKQCmy19tASIDE=" 238 "integrity": "sha1-sNBClG2ylTu50pKQCmy19tASIDE="
239 }, 239 },
  240 + "date-format": {
  241 + "version": "3.0.0",
  242 + "resolved": "https://registry.npm.taobao.org/date-format/download/date-format-3.0.0.tgz",
  243 + "integrity": "sha1-64eANlx9KxURB4+0keZHl4DzrZU="
  244 + },
240 "debug": { 245 "debug": {
241 "version": "2.6.9", 246 "version": "2.6.9",
242 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 247 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -311,6 +316,15 @@ @@ -311,6 +316,15 @@
311 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 316 "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
312 "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 317 "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
313 }, 318 },
  319 + "esdk-obs-nodejs": {
  320 + "version": "3.20.11",
  321 + "resolved": "https://registry.npm.taobao.org/esdk-obs-nodejs/download/esdk-obs-nodejs-3.20.11.tgz",
  322 + "integrity": "sha1-/bMuzu3qoT+xLgmCcgg8yM6MIsE=",
  323 + "requires": {
  324 + "log4js": "^6.3.0",
  325 + "xml2js": "^0.4.23"
  326 + }
  327 + },
314 "etag": { 328 "etag": {
315 "version": "1.8.1", 329 "version": "1.8.1",
316 "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 330 "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
@@ -367,6 +381,11 @@ @@ -367,6 +381,11 @@
367 "unpipe": "~1.0.0" 381 "unpipe": "~1.0.0"
368 } 382 }
369 }, 383 },
  384 + "flatted": {
  385 + "version": "2.0.2",
  386 + "resolved": "https://registry.npm.taobao.org/flatted/download/flatted-2.0.2.tgz",
  387 + "integrity": "sha1-RXWyHivO50NKqb5mL0t7X5wrUTg="
  388 + },
370 "follow-redirects": { 389 "follow-redirects": {
371 "version": "1.5.10", 390 "version": "1.5.10",
372 "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", 391 "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
@@ -395,6 +414,16 @@ @@ -395,6 +414,16 @@
395 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 414 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
396 "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 415 "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
397 }, 416 },
  417 + "fs-extra": {
  418 + "version": "8.1.0",
  419 + "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",
  420 + "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=",
  421 + "requires": {
  422 + "graceful-fs": "^4.2.0",
  423 + "jsonfile": "^4.0.0",
  424 + "universalify": "^0.1.0"
  425 + }
  426 + },
398 "fs.realpath": { 427 "fs.realpath": {
399 "version": "1.0.0", 428 "version": "1.0.0",
400 "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 429 "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -418,6 +447,11 @@ @@ -418,6 +447,11 @@
418 "path-is-absolute": "^1.0.0" 447 "path-is-absolute": "^1.0.0"
419 } 448 }
420 }, 449 },
  450 + "graceful-fs": {
  451 + "version": "4.2.4",
  452 + "resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.4.tgz",
  453 + "integrity": "sha1-Ila94U02MpWMRl68ltxGfKB6Kfs="
  454 + },
421 "graceful-readlink": { 455 "graceful-readlink": {
422 "version": "1.0.1", 456 "version": "1.0.1",
423 "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", 457 "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
@@ -542,6 +576,14 @@ @@ -542,6 +576,14 @@
542 "with": "~4.0.0" 576 "with": "~4.0.0"
543 } 577 }
544 }, 578 },
  579 + "jsonfile": {
  580 + "version": "4.0.0",
  581 + "resolved": "https://registry.npm.taobao.org/jsonfile/download/jsonfile-4.0.0.tgz",
  582 + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
  583 + "requires": {
  584 + "graceful-fs": "^4.1.6"
  585 + }
  586 + },
545 "jstransformer": { 587 "jstransformer": {
546 "version": "0.0.2", 588 "version": "0.0.2",
547 "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz", 589 "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-0.0.2.tgz",
@@ -564,6 +606,33 @@ @@ -564,6 +606,33 @@
564 "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", 606 "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
565 "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=" 607 "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4="
566 }, 608 },
  609 + "log4js": {
  610 + "version": "6.3.0",
  611 + "resolved": "https://registry.npm.taobao.org/log4js/download/log4js-6.3.0.tgz",
  612 + "integrity": "sha1-EN+vu0NDUaPjAnegC5h5RG9xW8s=",
  613 + "requires": {
  614 + "date-format": "^3.0.0",
  615 + "debug": "^4.1.1",
  616 + "flatted": "^2.0.1",
  617 + "rfdc": "^1.1.4",
  618 + "streamroller": "^2.2.4"
  619 + },
  620 + "dependencies": {
  621 + "debug": {
  622 + "version": "4.3.1",
  623 + "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",
  624 + "integrity": "sha1-8NIpxQXgxtjEmsVT0bE9wYP2su4=",
  625 + "requires": {
  626 + "ms": "2.1.2"
  627 + }
  628 + },
  629 + "ms": {
  630 + "version": "2.1.2",
  631 + "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",
  632 + "integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk="
  633 + }
  634 + }
  635 + },
567 "longest": { 636 "longest": {
568 "version": "1.0.1", 637 "version": "1.0.1",
569 "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", 638 "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
@@ -785,6 +854,11 @@ @@ -785,6 +854,11 @@
785 "path-parse": "^1.0.6" 854 "path-parse": "^1.0.6"
786 } 855 }
787 }, 856 },
  857 + "rfdc": {
  858 + "version": "1.2.0",
  859 + "resolved": "https://registry.npm.taobao.org/rfdc/download/rfdc-1.2.0.tgz",
  860 + "integrity": "sha1-npiUJY9I8oS0PDFDxoBwpPNzuUk="
  861 + },
788 "right-align": { 862 "right-align": {
789 "version": "0.1.3", 863 "version": "0.1.3",
790 "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", 864 "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
@@ -803,6 +877,11 @@ @@ -803,6 +877,11 @@
803 "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 877 "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
804 "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 878 "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
805 }, 879 },
  880 + "sax": {
  881 + "version": "1.2.4",
  882 + "resolved": "https://registry.npm.taobao.org/sax/download/sax-1.2.4.tgz",
  883 + "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk="
  884 + },
806 "send": { 885 "send": {
807 "version": "0.16.2", 886 "version": "0.16.2",
808 "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", 887 "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
@@ -862,6 +941,36 @@ @@ -862,6 +941,36 @@
862 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 941 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
863 "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 942 "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
864 }, 943 },
  944 + "streamroller": {
  945 + "version": "2.2.4",
  946 + "resolved": "https://registry.npm.taobao.org/streamroller/download/streamroller-2.2.4.tgz",
  947 + "integrity": "sha1-wZjO1C25QIamGTYIGHzoCl8rDlM=",
  948 + "requires": {
  949 + "date-format": "^2.1.0",
  950 + "debug": "^4.1.1",
  951 + "fs-extra": "^8.1.0"
  952 + },
  953 + "dependencies": {
  954 + "date-format": {
  955 + "version": "2.1.0",
  956 + "resolved": "https://registry.npm.taobao.org/date-format/download/date-format-2.1.0.tgz",
  957 + "integrity": "sha1-MdW16iEc9f12TNOLr50DPffhJc8="
  958 + },
  959 + "debug": {
  960 + "version": "4.3.1",
  961 + "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",
  962 + "integrity": "sha1-8NIpxQXgxtjEmsVT0bE9wYP2su4=",
  963 + "requires": {
  964 + "ms": "2.1.2"
  965 + }
  966 + },
  967 + "ms": {
  968 + "version": "2.1.2",
  969 + "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",
  970 + "integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk="
  971 + }
  972 + }
  973 + },
865 "string.prototype.trimleft": { 974 "string.prototype.trimleft": {
866 "version": "2.1.1", 975 "version": "2.1.1",
867 "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", 976 "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz",
@@ -954,6 +1063,11 @@ @@ -954,6 +1063,11 @@
954 "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", 1063 "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
955 "optional": true 1064 "optional": true
956 }, 1065 },
  1066 + "universalify": {
  1067 + "version": "0.1.2",
  1068 + "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",
  1069 + "integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY="
  1070 + },
957 "unpipe": { 1071 "unpipe": {
958 "version": "1.0.0", 1072 "version": "1.0.0",
959 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 1073 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -1017,6 +1131,20 @@ @@ -1017,6 +1131,20 @@
1017 "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1131 "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
1018 "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 1132 "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
1019 }, 1133 },
  1134 + "xml2js": {
  1135 + "version": "0.4.23",
  1136 + "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",
  1137 + "integrity": "sha1-oMaVFnUkIesqx1juTUzPWIQ+rGY=",
  1138 + "requires": {
  1139 + "sax": ">=0.6.0",
  1140 + "xmlbuilder": "~11.0.0"
  1141 + }
  1142 + },
  1143 + "xmlbuilder": {
  1144 + "version": "11.0.1",
  1145 + "resolved": "https://registry.npm.taobao.org/xmlbuilder/download/xmlbuilder-11.0.1.tgz",
  1146 + "integrity": "sha1-vpuuHIoEbnazESdyY0fQrXACvrM="
  1147 + },
1020 "yargs": { 1148 "yargs": {
1021 "version": "3.10.0", 1149 "version": "3.10.0",
1022 "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", 1150 "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 "child_process": "^1.0.2", 11 "child_process": "^1.0.2",
12 "cookie-parser": "~1.4.4", 12 "cookie-parser": "~1.4.4",
13 "debug": "~2.6.9", 13 "debug": "~2.6.9",
  14 + "esdk-obs-nodejs": "^3.20.11",
14 "express": "~4.16.1", 15 "express": "~4.16.1",
15 "http-errors": "~1.6.3", 16 "http-errors": "~1.6.3",
16 "jade": "~1.11.0", 17 "jade": "~1.11.0",
@@ -3,6 +3,7 @@ var router = express.Router(); @@ -3,6 +3,7 @@ var router = express.Router();
3 const { spawn, exec } = require('child_process'); 3 const { spawn, exec } = require('child_process');
4 const fs = require("fs"); 4 const fs = require("fs");
5 var path = require('path') 5 var path = require('path')
  6 +var ObsClient = require('esdk-obs-nodejs');
6 7
7 const method = require("../config/method") 8 const method = require("../config/method")
8 const config = require("../config/config") 9 const config = require("../config/config")
@@ -117,7 +118,7 @@ class MediaCreat { @@ -117,7 +118,7 @@ class MediaCreat {
117 // export DISPLAY=:7 118 // export DISPLAY=:7
118 // 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}` 119 // 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}`
119 // console.log("url", url) 120 // console.log("url", url)
120 - 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}` 121 + 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`
121 exec(url, { maxBuffer: 1073741824 }, (err, stdout, stderr) => { 122 exec(url, { maxBuffer: 1073741824 }, (err, stdout, stderr) => {
122 if (err != null) { 123 if (err != null) {
123 this.wrieLog(" 错误" + id + ":" + err) 124 this.wrieLog(" 错误" + id + ":" + err)
@@ -251,44 +252,73 @@ router.post('/recording', async function (req, res, next) { @@ -251,44 +252,73 @@ router.post('/recording', async function (req, res, next) {
251 252
252 // 判断该视频文件是否存在 253 // 判断该视频文件是否存在
253 router.post('/fileExists', async function (req, res, next) { 254 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 255 const body = req.body
257 - if(!body.siteId) {  
258 - res.send({ code: 2,message:"机构编码无效" }); 256 + if (!body.siteId) {
  257 + res.send({code: 2, message: "机构编码无效"});
259 return 258 return
260 } 259 }
261 - if(!body.classId) {  
262 - res.send({ code: 3,message:"课堂号无效" }); 260 + if (!body.classId) {
  261 + res.send({code: 3, message: "课堂号无效"});
263 return 262 return
264 } 263 }
265 - let timeDir = PROJECTCATALOG + "/media/" + body.siteId  
266 264
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 - let fileTime = ""  
275 - for(let i=0;i<timeFiles.length;i++){  
276 - let classDir = `${timeDir}/${timeFiles[i]}`  
277 - const classFiles = fs.readdirSync(classDir)  
278 - if(classFiles.indexOf(classIdStr) > -1){  
279 - fileTime = timeFiles[i]  
280 - isFile = true  
281 - break  
282 - }  
283 - }  
284 - if(isFile){  
285 - let classUrl = `https://xdymp4.xuedianyun.com/oss/${body.siteId}/${fileTime}/${body.classId}.mp4`  
286 - res.send({ code: 0,message:"文件已生成",classUrl });  
287 - }else { 265 + // if(!body.classStartTime) {
  266 + // res.send({ code: 4,message:"时间不存在" });
  267 + // return
  268 + // }
  269 +
  270 + // 创建ObsClient实例
  271 + var obsClient = new ObsClient({
  272 + access_key_id: 'FY27OD11ZJVC385AOTW9',
  273 + secret_access_key: 'ZqnfRjaseCtuRbE79GvqkPiYUdT83ZbB0oU7fBo3',
  274 + server: 'obs.cn-north-4.myhuaweicloud.com'
  275 + });
  276 +
  277 + let isVideo = false
  278 + let url = ""
  279 + let Prefix = ""
  280 + if (body.classStartTime) {
  281 + Prefix = `oss/${body.siteId}/${body.classStartTime}/${body.classId}.mp4`
  282 + obsClient.listObjects({
  283 + Bucket: 'xdymp4',
  284 + Prefix: Prefix,
  285 + // MaxKeys:1
  286 + }, (err, result) => {
  287 + if (err) {
  288 + console.error('Error-->' + err);
  289 + } else {
  290 + if (result.CommonMsg.Status == 200) {
  291 + let content = result.InterfaceResult.Contents
  292 + if (content && content.length) {
  293 + if (content[0].Key) {
  294 + isVideo = true
  295 + url = content[0].Key
  296 + }
  297 + }
  298 + // for(let i=0;i<result.InterfaceResult.Contents.length;i++){
  299 + // let item = result.InterfaceResult.Contents[i]
  300 + // if(item.Key && item.Key.indexOf(body.classId) > -1){
  301 + // isVideo = true
  302 + // url = item.Key
  303 + // break
  304 + // }
  305 + // }
  306 + }
  307 + }
  308 + if (!isVideo) {
  309 + let classUrl = `https://pclive.xuedianyun.com/pcBase/pclive2/release/index.html?portalIP=saas.xuedianyun.com&portalPort=80&classId=${body.classId}&channels=2&playRecord=1#/`
  310 + res.send({code: 1, message: "文件未生成", classUrl});
  311 + } else {
  312 + let classUrl = `https://xdymp4.xuedianyun.com/${url}`
  313 + res.send({code: 0, message: "文件已生成", classUrl});
  314 + }
  315 + // 关闭obsClient
  316 + obsClient.close();
  317 + });
  318 + }else{
288 let classUrl = `https://pclive.xuedianyun.com/pcBase/pclive2/release/index.html?portalIP=saas.xuedianyun.com&portalPort=80&classId=${body.classId}&channels=2&playRecord=1#/` 319 let classUrl = `https://pclive.xuedianyun.com/pcBase/pclive2/release/index.html?portalIP=saas.xuedianyun.com&portalPort=80&classId=${body.classId}&channels=2&playRecord=1#/`
289 - res.send({ code: 1,message:"文件未生成",classUrl }); 320 + res.send({code: 1, message: "文件未生成", classUrl});
290 } 321 }
291 -  
292 }) 322 })
293 323
294 module.exports = router; 324 module.exports = router;