tronclass-auto 1.3.9 → 1.4.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.3.9",
3
+ "version": "1.4.0",
4
4
  "description": "自動觀看 eclass/TronClass 影片、填寫表單的 CLI 工具",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -157,9 +157,36 @@ async function processCourse(page, courseId, stats) {
157
157
  }
158
158
  const success = await watchVideo(page, stats);
159
159
  if (success) {
160
- markDone(courseId, act.id);
161
- done++;
162
- console.log(chalk.green(' ✓ Saved'));
160
+ await page.waitForTimeout(5000);
161
+ await page.goto(`${BASE_URL}/course/${courseId}/content#/`, {
162
+ waitUntil: 'domcontentloaded', timeout: 15000
163
+ }).catch(() => {});
164
+ await page.waitForTimeout(3000);
165
+
166
+ const serverComplete = await page.evaluate((actId) => {
167
+ const el = document.querySelector('.learning-activities');
168
+ if (!el) return false;
169
+ const scope = angular.element(el).scope();
170
+ if (!scope) return false;
171
+ const activities = document.querySelectorAll('.learning-activity.sortable');
172
+ for (const actEl of activities) {
173
+ const actScope = angular.element(actEl).scope();
174
+ if (!actScope || !actScope.activity) continue;
175
+ if (actScope.activity.id == actId) {
176
+ try { return scope.getActivityCompleteness(actScope.activity) === 'full'; } catch (e) {}
177
+ }
178
+ }
179
+ return false;
180
+ }, act.id);
181
+
182
+ if (serverComplete) {
183
+ markDone(courseId, act.id);
184
+ done++;
185
+ console.log(chalk.green(' ✓ Saved (server confirmed)'));
186
+ } else {
187
+ console.log(chalk.yellow(' Server not confirmed yet, will retry next run'));
188
+ fail++;
189
+ }
163
190
  } else {
164
191
  fail++;
165
192
  }
package/src/video.js CHANGED
@@ -101,8 +101,13 @@ async function watchYouTube(page, stats) {
101
101
  return 180;
102
102
  });
103
103
 
104
- const waitTime = Math.ceil(ytDuration / 2) + 30;
105
- log(chalk.blue(` ~${formatTime(ytDuration)} video → ~${formatTime(waitTime)} (2x)`));
104
+ const waitTime = ytDuration + 30;
105
+ log(chalk.blue(` ~${formatTime(ytDuration)} video → ~${formatTime(waitTime)} (YouTube 1x safe)`));
106
+
107
+ if (stats) {
108
+ stats.currentVideoDuration = ytDuration;
109
+ stats.currentVideoElapsed = 0;
110
+ }
106
111
 
107
112
  let elapsed = 0;
108
113
  let lastPct = -1;