@lzwme/m3u8-dl 1.1.2 → 1.1.3

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.
@@ -405,9 +405,9 @@ class DLServer {
405
405
  const urlsToPause = all ? [...this.dlCache.keys()] : urls;
406
406
  const list = [];
407
407
  for (const url of urlsToPause) {
408
- const item = this.dlCache.get(url);
408
+ const { workPoll, ...item } = this.dlCache.get(url);
409
409
  if (item?.status === 'resume') {
410
- (0, m3u8_download_js_1.m3u8DLStop)(url, item.workPoll);
410
+ (0, m3u8_download_js_1.m3u8DLStop)(url, workPoll);
411
411
  item.status = item.tsSuccess === item.tsCount ? 'done' : 'pause';
412
412
  list.push(item);
413
413
  }
@@ -422,7 +422,7 @@ class DLServer {
422
422
  const urlsToResume = all ? [...this.dlCache.keys()] : urls;
423
423
  const list = [];
424
424
  for (const url of urlsToResume) {
425
- const item = this.dlCache.get(url);
425
+ const { workPoll, ...item } = this.dlCache.get(url);
426
426
  if (['pause', 'error'].includes(item?.status)) {
427
427
  this.startDownload(url, item.options);
428
428
  list.push(item);
@@ -445,6 +445,7 @@ class DLServer {
445
445
  if (item) {
446
446
  (0, m3u8_download_js_1.m3u8DLStop)(url, item.workPoll);
447
447
  this.dlCache.delete(url);
448
+ list.push(item.url);
448
449
  if (deleteCache && item.current?.tsOut) {
449
450
  const cacheDir = (0, node_path_1.dirname)(item.current.tsOut);
450
451
  if ((0, node_fs_1.existsSync)(cacheDir))
@@ -457,12 +458,11 @@ class DLServer {
457
458
  (0, node_fs_1.unlinkSync)(filepath);
458
459
  });
459
460
  }
460
- list.push(item);
461
461
  }
462
462
  }
463
463
  const count = list.length;
464
464
  if (count)
465
- this.wsSend('progress', list);
465
+ this.wsSend('delete', list);
466
466
  res.json({ message: `已删除 ${count} 个下载任务`, code: 0, count });
467
467
  });
468
468
  app.get(/^\/localplay\/(.*)$/, (req, res) => {
package/client/index.html CHANGED
@@ -719,6 +719,9 @@ services:
719
719
  // this.forceUpdate();
720
720
  });
721
721
  break;
722
+ case 'delete':
723
+ if (Array.isArray(data)) data.forEach(url => delete this.tasks[url]);
724
+ break;
722
725
  case 'queueStatus':
723
726
  this.queueStatus = data;
724
727
  break;
@@ -928,7 +931,7 @@ services:
928
931
  },
929
932
  /** 边下边播 */
930
933
  localPlay: function (task) {
931
- const url = location.origin + '/localplay/' + encodeURIComponent(task.localVideo || task.localM3u8);
934
+ const url = location.origin + '/localplay/' + (task.localVideo || task.localM3u8);
932
935
  console.log(task);
933
936
  // return window.open(`./play.html?url=${encodeURIComponent(url)}`);
934
937
  Swal.fire({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lzwme/m3u8-dl",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Batch download of m3u8 files and convert to mp4",
5
5
  "main": "cjs/index.js",
6
6
  "types": "cjs/index.d.ts",