tor-dl 1.0.2 → 1.0.4

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.
Files changed (51) hide show
  1. package/README.md +85 -192
  2. package/dist/cli/display.d.ts.map +1 -1
  3. package/dist/cli/display.js +13 -7
  4. package/dist/cli/display.js.map +1 -1
  5. package/dist/cli/parser.d.ts.map +1 -1
  6. package/dist/cli/parser.js +59 -37
  7. package/dist/cli/parser.js.map +1 -1
  8. package/dist/commands/download.d.ts +1 -1
  9. package/dist/commands/download.d.ts.map +1 -1
  10. package/dist/commands/download.js +55 -49
  11. package/dist/commands/download.js.map +1 -1
  12. package/dist/commands/search.d.ts.map +1 -1
  13. package/dist/commands/search.js +29 -1
  14. package/dist/commands/search.js.map +1 -1
  15. package/dist/download/engine.d.ts +1 -3
  16. package/dist/download/engine.d.ts.map +1 -1
  17. package/dist/download/engine.js +0 -129
  18. package/dist/download/engine.js.map +1 -1
  19. package/dist/filters/seeds.d.ts +1 -1
  20. package/dist/filters/seeds.d.ts.map +1 -1
  21. package/dist/filters/seeds.js +4 -1
  22. package/dist/filters/seeds.js.map +1 -1
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +0 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/sources/nyaa.d.ts.map +1 -1
  28. package/dist/sources/nyaa.js +3 -0
  29. package/dist/sources/nyaa.js.map +1 -1
  30. package/dist/sources/thepiratebay.d.ts.map +1 -1
  31. package/dist/sources/thepiratebay.js +1 -0
  32. package/dist/sources/thepiratebay.js.map +1 -1
  33. package/dist/sources/yts.d.ts.map +1 -1
  34. package/dist/sources/yts.js +1 -0
  35. package/dist/sources/yts.js.map +1 -1
  36. package/dist/types.d.ts +2 -0
  37. package/dist/types.d.ts.map +1 -1
  38. package/help.txt +30 -0
  39. package/package.json +3 -5
  40. package/src/cli/display.ts +15 -7
  41. package/src/cli/parser.ts +62 -40
  42. package/src/commands/download.ts +48 -15
  43. package/src/commands/search.ts +84 -52
  44. package/src/download/engine.ts +1 -144
  45. package/src/filters/seeds.ts +4 -1
  46. package/src/index.ts +0 -1
  47. package/src/sources/nyaa.ts +3 -0
  48. package/src/sources/thepiratebay.ts +1 -0
  49. package/src/sources/yts.ts +1 -0
  50. package/src/types.ts +2 -0
  51. package/src/cli/progress.ts +0 -78
@@ -1,78 +0,0 @@
1
- import cliProgress from 'cli-progress';
2
- import chalk from 'chalk';
3
-
4
- export class DownloadProgress {
5
- private bar: cliProgress.SingleBar;
6
- private startTime: number;
7
- private totalBytes: number = 0;
8
- private downloadedBytes: number = 0;
9
-
10
- constructor() {
11
- this.startTime = Date.now();
12
- this.bar = new cliProgress.SingleBar({
13
- format: '[{bar}] {percentage}% | {speed} | ETA: {eta} | {downloaded}',
14
- barCompleteChar: '\u2588',
15
- barIncompleteChar: '\u2591',
16
- hideCursor: true,
17
- fps: 10,
18
- etaAsynchronous: true
19
- });
20
- }
21
-
22
- start(total: number): void {
23
- this.totalBytes = total;
24
- this.bar.start(total, 0, {
25
- speed: '0 B/s',
26
- downloaded: '0 MB'
27
- });
28
- }
29
-
30
- update(downloaded: number, total: number): void {
31
- this.downloadedBytes = downloaded;
32
- this.totalBytes = total || this.totalBytes;
33
-
34
- const speed = this.calculateSpeed();
35
- const eta = this.calculateETA();
36
- const downloadedMB = (this.downloadedBytes / (1024 * 1024)).toFixed(2);
37
-
38
- this.bar.update(this.downloadedBytes, {
39
- speed,
40
- downloaded: `${downloadedMB} MB`,
41
- eta
42
- });
43
- }
44
-
45
- private calculateSpeed(): string {
46
- const elapsed = (Date.now() - this.startTime) / 1000;
47
- const bytesPerSecond = elapsed > 0 ? this.downloadedBytes / elapsed : 0;
48
- return this.formatBytes(bytesPerSecond) + '/s';
49
- }
50
-
51
- private calculateETA(): string {
52
- const elapsed = (Date.now() - this.startTime) / 1000;
53
- if (this.downloadedBytes === 0 || this.totalBytes === 0) return 'N/A';
54
-
55
- const speed = this.downloadedBytes / elapsed;
56
- const remaining = this.totalBytes - this.downloadedBytes;
57
- const seconds = remaining / speed;
58
-
59
- if (seconds < 60) return `${Math.round(seconds)}s`;
60
- if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${Math.round(seconds % 60)}s`;
61
- return `${Math.floor(seconds / 3600)}h ${Math.floor((seconds % 3600) / 60)}m`;
62
- }
63
-
64
- private formatBytes(bytes: number): string {
65
- if (bytes < 1024) return bytes + ' B';
66
- if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB';
67
- if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(2) + ' MB';
68
- return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
69
- }
70
-
71
- stop(): void {
72
- this.bar.stop();
73
- }
74
-
75
- getTotalDownloaded(): number {
76
- return this.downloadedBytes;
77
- }
78
- }