tronclass-auto 1.5.5 → 1.6.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tronclass-auto",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "自動觀看 eclass/TronClass 影片、填寫表單的 CLI 工具",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -110,7 +110,7 @@ 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(8000);
113
+ await page.waitForTimeout(15000);
114
114
 
115
115
  if (!page.url().includes('learning-activity')) {
116
116
  console.log(chalk.yellow(' Page redirect, skipping'));
@@ -155,13 +155,15 @@ async function processCourse(page, courseId, stats) {
155
155
  }
156
156
  const success = await watchVideo(page, stats);
157
157
  if (success) {
158
+ console.log(chalk.gray(' Waiting for platform tracking...'));
159
+ await page.waitForTimeout(30000);
160
+
158
161
  let serverComplete = false;
159
- for (let attempt = 0; attempt < 5; attempt++) {
160
- await page.waitForTimeout(10000);
162
+ try {
161
163
  await page.goto(`${BASE_URL}/course/${courseId}/content#/`, {
162
- waitUntil: 'domcontentloaded', timeout: 15000
163
- }).catch(() => {});
164
- await page.waitForTimeout(5000);
164
+ waitUntil: 'domcontentloaded', timeout: 20000
165
+ });
166
+ await page.waitForTimeout(8000);
165
167
 
166
168
  serverComplete = await page.evaluate((actId) => {
167
169
  const el = document.querySelector('.learning-activities');
@@ -178,9 +180,8 @@ async function processCourse(page, courseId, stats) {
178
180
  }
179
181
  return false;
180
182
  }, act.id);
181
-
182
- if (serverComplete) break;
183
- console.log(chalk.gray(` Checking server... (${attempt + 1}/5)`));
183
+ } catch (e) {
184
+ console.log(chalk.gray(` Server check error: ${e.message.substring(0, 40)}`));
184
185
  }
185
186
 
186
187
  if (serverComplete) {
@@ -188,7 +189,7 @@ async function processCourse(page, courseId, stats) {
188
189
  done++;
189
190
  console.log(chalk.green(' ✓ Saved (server confirmed)'));
190
191
  } else {
191
- console.log(chalk.yellow(' Server not confirmed after retries, skipping'));
192
+ console.log(chalk.yellow(' Server not confirmed, skipping'));
192
193
  triedIds.add(act.id);
193
194
  fail++;
194
195
  }
package/src/video.js CHANGED
@@ -116,11 +116,6 @@ async function watchYouTube(page, stats) {
116
116
  } catch (e) {
117
117
  log(chalk.yellow(` YouTube error: ${e.message}`));
118
118
  }
119
- log(chalk.yellow(` State: ${state2}`));
120
- }
121
- } catch (e) {
122
- log(chalk.yellow(` YouTube error: ${e.message}`));
123
- }
124
119
 
125
120
  await page.waitForTimeout(2000);
126
121