tokwatchr 0.6.1 → 0.6.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.
package/dist/index.d.mts CHANGED
@@ -101,6 +101,8 @@ interface RemuxInfo {
101
101
  filePath: string;
102
102
  /** Input file size in MB. */
103
103
  inputSizeMB: number;
104
+ /** Output file size in MB. Only set when status is "completed". */
105
+ outputSizeMB?: number;
104
106
  /** Remux status: started → completed (with outputPath) or failed (keeping .ts). */
105
107
  status: "started" | "completed" | "failed";
106
108
  /** Output file path. Only set when status is "completed". */
package/dist/index.mjs CHANGED
@@ -658,7 +658,7 @@ var TikTokLiveDownloader = class {
658
658
  this.impIt = createClient({
659
659
  browser: this.options.browser,
660
660
  proxyUrl: this.options.proxyUrl,
661
- timeout: this.options.timeout,
661
+ timeout: this.options.timeout * 1e3,
662
662
  headers: this.options.headers,
663
663
  cookieJar: this.options.cookieJar
664
664
  });
@@ -930,7 +930,7 @@ var TikTokLiveDownloader = class {
930
930
  signal: this.abortController.signal,
931
931
  onProgress,
932
932
  maxDuration: segmentMaxDuration < Infinity ? segmentMaxDuration : void 0,
933
- timeout: this.options.timeout
933
+ timeout: this.options.timeout * 1e3
934
934
  });
935
935
  return {
936
936
  filePath: tsPath,
@@ -988,6 +988,11 @@ var TikTokLiveDownloader = class {
988
988
  });
989
989
  try {
990
990
  await this.remuxAndNormalize(this.options.ffmpegPath, inputPath, finalPath);
991
+ let realSizeBytes = tsResult.sizeBytes;
992
+ try {
993
+ const { statSync } = await import("node:fs");
994
+ realSizeBytes = statSync(finalPath).size;
995
+ } catch {}
991
996
  try {
992
997
  const { unlinkSync } = await import("node:fs");
993
998
  unlinkSync(inputPath);
@@ -996,11 +1001,14 @@ var TikTokLiveDownloader = class {
996
1001
  filePath: inputPath,
997
1002
  outputPath: finalPath,
998
1003
  inputSizeMB: tsResult.sizeMB,
1004
+ outputSizeMB: realSizeBytes / (1024 * 1024),
999
1005
  status: "completed"
1000
1006
  });
1001
1007
  return {
1002
1008
  ...tsResult,
1003
1009
  filePath: finalPath,
1010
+ sizeBytes: realSizeBytes,
1011
+ sizeMB: realSizeBytes / (1024 * 1024),
1004
1012
  format: finalExt
1005
1013
  };
1006
1014
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokwatchr",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Download TikTok livestreams. Given a username, download the livestream.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -77,7 +77,7 @@ export class TikTokLiveDownloader {
77
77
  this.impIt = createClient({
78
78
  browser: this.options.browser,
79
79
  proxyUrl: this.options.proxyUrl,
80
- timeout: this.options.timeout,
80
+ timeout: this.options.timeout * 1_000,
81
81
  headers: this.options.headers,
82
82
  cookieJar: this.options.cookieJar,
83
83
  });
@@ -500,7 +500,7 @@ export class TikTokLiveDownloader {
500
500
  onProgress,
501
501
  maxDuration:
502
502
  segmentMaxDuration < Infinity ? segmentMaxDuration : undefined,
503
- timeout: this.options.timeout,
503
+ timeout: this.options.timeout * 1_000,
504
504
  });
505
505
 
506
506
  return {
@@ -584,7 +584,16 @@ export class TikTokLiveDownloader {
584
584
  inputPath,
585
585
  finalPath,
586
586
  );
587
- // Remux succeeded — delete temp .ts
587
+ // Remux succeeded — stat the real output size
588
+ let realSizeBytes = tsResult.sizeBytes;
589
+ try {
590
+ const { statSync } = await import("node:fs");
591
+ realSizeBytes = statSync(finalPath).size;
592
+ } catch {
593
+ // fall back to input size if stat fails
594
+ }
595
+
596
+ // Delete temp .ts
588
597
  try {
589
598
  const { unlinkSync } = await import("node:fs");
590
599
  unlinkSync(inputPath);
@@ -596,12 +605,15 @@ export class TikTokLiveDownloader {
596
605
  filePath: inputPath,
597
606
  outputPath: finalPath,
598
607
  inputSizeMB: tsResult.sizeMB,
608
+ outputSizeMB: realSizeBytes / (1024 * 1024),
599
609
  status: "completed",
600
610
  });
601
611
 
602
612
  return {
603
613
  ...tsResult,
604
614
  filePath: finalPath,
615
+ sizeBytes: realSizeBytes,
616
+ sizeMB: realSizeBytes / (1024 * 1024),
605
617
  format: finalExt as "mp4" | "mkv",
606
618
  };
607
619
  } catch (err) {
package/src/types.ts CHANGED
@@ -128,6 +128,8 @@ export interface RemuxInfo {
128
128
  filePath: string;
129
129
  /** Input file size in MB. */
130
130
  inputSizeMB: number;
131
+ /** Output file size in MB. Only set when status is "completed". */
132
+ outputSizeMB?: number;
131
133
  /** Remux status: started → completed (with outputPath) or failed (keeping .ts). */
132
134
  status: "started" | "completed" | "failed";
133
135
  /** Output file path. Only set when status is "completed". */