diff --git a/applacation.js b/applacation.js index b679bfe..1d2d2b2 100644 --- a/applacation.js +++ b/applacation.js @@ -1,3 +1,4 @@ module.exports = { - uploade:'/Users/fzy/project/koa2_Sequelize_project/uploads/' ///Users/fzy/project/koa2_Sequelize_project/uploads/ + uploade:'/Users/fzy/project/koa2_Sequelize_project/uploads/', ///Users/fzy/project/koa2_Sequelize_project/uploads/ + recordPath:'http://networkschool.xuedianyun.com:8899/' } \ No newline at end of file diff --git a/services/recordInfoService.js b/services/recordInfoService.js index 4d9e324..e485479 100644 --- a/services/recordInfoService.js +++ b/services/recordInfoService.js @@ -2,6 +2,8 @@ const recordInfo =require( '../model/RecordInfoModel') const tencentRecordInfoModel =require( '../model/tencentRecordInfoModel') const callfile = require('child_process'); const fs = require('fs'); +const moment = require('moment') +const applacation = require('../applacation') function recordInfoService(){ @@ -45,13 +47,40 @@ recordInfoService.prototype.tencentRecordInfo = async(channelId)=>{ recordInfoService.prototype.getRecordFileURL = async(path,time)=>{ try { - let pathURL = '/netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/'+time+"/"+path - let myPath = '/Users/fzy/Downloads/Agora_Recording_SDK_for_Linux_FULL/samples/'+time+"/"+path - let shell = `/20171011/markettest_1227676976_023539/` - // let filenames = await callfile.exec(myPath) - let files=fs.readdirSync(pathURL); - console.log(files) - return files + //let onlinePath = '/netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/' + let onlinePath = '/Users/fzy/Downloads/Agora_Recording_SDK_for_Linux_FULL/samples/' + var backFile=[]; + var fileU + let addrecord = await recordInfo.findAll({where:{channel:path}}); + addrecord.forEach(function(record){ + let date1 = moment(Number( record.createTime)).format('YYYYMMDD') + let date2 = moment(Number(record.createTime)-8*60*60*1000).format('YYYYMMDDhhmmss') + let channeFile = onlinePath+date1; + let fschannefiles=fs.readdirSync(channeFile); + fschannefiles.forEach(function(cfile){ + if(record.channel == cfile.split('_')[0]+'_'+cfile.split("_")[1]){ + let pathURL = onlinePath+date1+"/"+cfile; + let files=fs.readdirSync(pathURL); + files.forEach(function(file){ + let type = file.split('.'); + if(type[1] != 'm3u8'){ + }else{ + let fileN = type[0].split('_'); + if(date2==fileN[1].slice(0,fileN[1].length-3)){ + backFile.push({ + channel:record.channel, + uid:record.uid, + createTime:record.createTime, + fileUrl:applacation.recordPath+date1+'/'+cfile+'/'+file + }) + console.log('找到文件',files) + } + } + }) + } + }) + }) + return backFile } catch (error) { throw error; }