tronclass-auto 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +19 -13
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -110,27 +110,33 @@ async function processCourse(page, courseId, stats) {
|
|
|
110
110
|
try {
|
|
111
111
|
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 15000 });
|
|
112
112
|
} catch (e) {}
|
|
113
|
-
await page.waitForTimeout(
|
|
113
|
+
await page.waitForTimeout(8000);
|
|
114
114
|
|
|
115
115
|
if (!page.url().includes('learning-activity')) {
|
|
116
|
-
console.log(chalk.yellow('
|
|
116
|
+
console.log(chalk.yellow(' Page redirect, skipping'));
|
|
117
117
|
markLocked(courseId, act.id);
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
const hasVideo = await page.evaluate(() =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
console.log(chalk.yellow(' Locked (no video), stopping this course'));
|
|
126
|
-
markLocked(courseId, act.id);
|
|
127
|
-
break;
|
|
121
|
+
const hasVideo = await page.evaluate(() => {
|
|
122
|
+
if (document.querySelector('video')) return true;
|
|
123
|
+
for (const f of document.querySelectorAll('iframe')) {
|
|
124
|
+
try { if (f.contentDocument && f.contentDocument.querySelector('video')) return true; } catch (e) {}
|
|
128
125
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
return false;
|
|
127
|
+
});
|
|
128
|
+
if (!hasVideo) {
|
|
129
|
+
console.log(chalk.yellow(' No video, waiting more...'));
|
|
130
|
+
await page.waitForTimeout(10000);
|
|
131
|
+
const hasVideoNow = await page.evaluate(() => {
|
|
132
|
+
if (document.querySelector('video')) return true;
|
|
133
|
+
for (const f of document.querySelectorAll('iframe')) {
|
|
134
|
+
try { if (f.contentDocument && f.contentDocument.querySelector('video')) return true; } catch (e) {}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
});
|
|
132
138
|
if (!hasVideoNow) {
|
|
133
|
-
console.log(chalk.yellow(' Still no video,
|
|
139
|
+
console.log(chalk.yellow(' Still no video, skipping (not a video activity)'));
|
|
134
140
|
markLocked(courseId, act.id);
|
|
135
141
|
break;
|
|
136
142
|
}
|