张艾宸

一次性获取所有录制课堂的数据 1.1

... ... @@ -3,7 +3,7 @@ const GETCLASSURLPARAMETER = {
siteId:["BuzzKID","kuaikuenglish"],
key:"xdymp4record20191225",
page:1,
maxMedia:1,
maxMedia:3,
}
const PROJECTWINCATALOG = "E:/project/web_capture_release/win-x64"
... ...
... ... @@ -24,29 +24,27 @@ class MediaCreat {
constructor() { }
// 取出所有数据
async allData() {
let page = 1
className = siteIds.shift()
let page = 1
if (className) {
let result = await getRequestClassIds(GETCLASSURL, className, GETCLASSURLPARAMETER.key, startTime, endTime, page)
parentData[result.data.data.siteId] = []
parentData[result.data.data.siteId] = new Set()
for (let j = 0; j < result.data.data.list.length; j++) {
classid.push(result.data.data.list[j])
parentData[result.data.data.siteId].add(result.data.data.list[j]['classId'])
}
const { siteId, list, totalPage } = result.data.data
for (let i = page += 1; i <= totalPage; i++) {
let result = await getRequestClassIds(GETCLASSURL, className, GETCLASSURLPARAMETER.key, startTime, endTime, i)
for (let j = 0; j < result.data.data.list.length; j++) {
classid.push(result.data.data.list[j])
parentData[result.data.data.siteId].add(result.data.data.list[j]['classId'])
}
}
parentData[result.data.data.siteId] = Array.from(parentData[result.data.data.siteId])
classid = classid.reduce(function (item, next) {
classobj[next.classId] ? '' : classobj[next.classId] = true && item.push(next);
return item;
}, []);
for (let i = 0; i < classid.length; i++) {
parentData[result.data.data.siteId].push(classid[i].classId)
if (siteIds.length) {
return await new MediaCreat().allData()
}
return true
} else {
... ... @@ -93,15 +91,6 @@ class MediaCreat {
if (classid.length) {
let shiftData = classid.shift()
new MediaCreat().mediaCreat(shiftData['classId'], shiftData['siteId'])
} else {
if (siteIds.length) {
// 如果有多家需要录制,继续录制下一家
let isAppend = await new MediaCreat().allData()
if (isAppend) {
let shiftData = classid.shift()
new MediaCreat().mediaCreat(shiftData['classId'], shiftData['siteId'])
}
}
}
}
});
... ... @@ -110,8 +99,13 @@ class MediaCreat {
router.get('/', async function (req, res, next) {
let isAppend = await new MediaCreat().allData()
if (isAppend) {
let result = await new MediaCreat().allData()
if (result) {
// 去重
classid = classid.reduce(function (item, next) {
classobj[next.classId] ? '' : classobj[next.classId] = true && item.push(next);
return item;
}, []);
if (classid.length) {
for (let i = 0; i < GETCLASSURLPARAMETER.maxMedia; i++) {
let shiftData = classid.shift()
... ... @@ -122,9 +116,8 @@ router.get('/', async function (req, res, next) {
}
}
}
res.send({ code: "0" });
}
res.render('index', { title: 'Express' });
});
module.exports = router;
... ...