mediatuna 1.21.11

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/lib/trash.js ADDED
@@ -0,0 +1,31 @@
1
+ import { execFile } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import path from 'path';
4
+
5
+ const execFileAsync = promisify(execFile);
6
+
7
+ export async function moveToTrash(filePath, { execFileFn = execFileAsync, platform = process.platform } = {}) {
8
+ const resolved = path.resolve(filePath);
9
+ if (platform === 'win32') {
10
+ const script = [
11
+ 'Add-Type -AssemblyName Microsoft.VisualBasic',
12
+ `$p = ${JSON.stringify(resolved)}`,
13
+ 'if (-not (Test-Path -LiteralPath $p)) { throw "path not found" }',
14
+ "[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($p, 'OnlyErrorDialogs', 'SendToRecycleBin')",
15
+ ].join('; ');
16
+ await execFileFn('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script]);
17
+ return;
18
+ }
19
+ if (platform === 'darwin') {
20
+ await execFileFn('osascript', [
21
+ '-e',
22
+ `tell application "Finder" to delete POSIX file ${JSON.stringify(resolved)}`,
23
+ ]);
24
+ return;
25
+ }
26
+ try {
27
+ await execFileFn('gio', ['trash', resolved]);
28
+ } catch {
29
+ await execFileFn('trash-put', [resolved]);
30
+ }
31
+ }
package/lib/verify.js ADDED
@@ -0,0 +1,60 @@
1
+ import fs from 'fs';
2
+ import { execFileSync } from 'child_process';
3
+ import { lameQuality } from './audio-policy.js';
4
+ import { formatSize } from './format.js';
5
+ import { formatMtimeDate } from './paths.js';
6
+ import { getFormatTags, getMetadata } from './probe.js';
7
+ import { findTagValue, hasDateTag, IMPORTANT_TAG_NAMES } from './tags.js';
8
+
9
+ export function verifyAudioTags(sourceMeta, outPath) {
10
+ const warnings = [];
11
+ const dest = getFormatTags(outPath);
12
+ const dropped = sourceMeta.tagCount - dest.tagCount;
13
+ if (dropped >= 3) {
14
+ warnings.push(`${dropped} tags dropped (${sourceMeta.tagCount} → ${dest.tagCount})`);
15
+ }
16
+ for (const name of IMPORTANT_TAG_NAMES) {
17
+ if (findTagValue(sourceMeta.tags, name) && !findTagValue(dest.tags, name)) {
18
+ warnings.push(`missing ${name} tag in output`);
19
+ }
20
+ }
21
+ return warnings;
22
+ }
23
+
24
+ export function durationToleranceSeconds(expectedDuration) {
25
+ return Math.max(2, expectedDuration * 0.05);
26
+ }
27
+
28
+ export function durationWithinTolerance(actualDuration, expectedDuration) {
29
+ if (!(expectedDuration > 0) || !(actualDuration > 0)) return true;
30
+ return Math.abs(actualDuration - expectedDuration) <= durationToleranceSeconds(expectedDuration);
31
+ }
32
+
33
+ export function verifyOutput(outPath, expectedDuration, expectedType = 'video', verifyContext = null) {
34
+ const meta = getMetadata(outPath);
35
+ if (meta.mediaType !== expectedType) {
36
+ return { ok: false, reason: expectedType === 'audio' ? 'output file has no audio stream' : 'output file is unreadable' };
37
+ }
38
+ if (!durationWithinTolerance(meta.duration, expectedDuration)) {
39
+ return {
40
+ ok: false,
41
+ reason: `duration mismatch (source ${expectedDuration.toFixed(1)}s, output ${meta.duration.toFixed(1)}s)`,
42
+ };
43
+ }
44
+
45
+ const warnings = [];
46
+ if (expectedType === 'audio' && verifyContext?.sourceMeta) {
47
+ warnings.push(...verifyAudioTags(verifyContext.sourceMeta, outPath));
48
+ if (verifyContext.sourceSize) {
49
+ const outSize = fs.statSync(outPath).size;
50
+ if (outSize === 0) {
51
+ return { ok: false, reason: 'output file is empty' };
52
+ }
53
+ if (outSize > verifyContext.sourceSize * 10) {
54
+ warnings.push(`output (${formatSize(outSize)}) unusually large vs source (${formatSize(verifyContext.sourceSize)})`);
55
+ }
56
+ }
57
+ }
58
+
59
+ return { ok: true, duration: meta.duration, warnings };
60
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "mediatuna",
3
+ "version": "1.21.11",
4
+ "type": "module",
5
+ "description": "Make sure the old files can still play. Local convert to MP4 and MP3, dates kept.",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "mediatuna": "index.js"
9
+ },
10
+ "dependencies": {
11
+ "cli-progress": "^3.12.0",
12
+ "glob": "^11.0.0"
13
+ },
14
+ "keywords": [
15
+ "video",
16
+ "audio",
17
+ "media",
18
+ "converter",
19
+ "ffmpeg",
20
+ "nvenc",
21
+ "batch",
22
+ "metadata"
23
+ ],
24
+ "author": "Catalyst Forge LLC",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/Catalyst-Forge-LLC/mediatuna.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/Catalyst-Forge-LLC/mediatuna/issues"
32
+ },
33
+ "homepage": "https://mediatuna.dev",
34
+ "files": [
35
+ "index.js",
36
+ "lib"
37
+ ],
38
+ "scripts": {
39
+ "start": "node index.js",
40
+ "convert": "node index.js",
41
+ "test": "node --test test/**/*.test.js",
42
+ "test:ffmpeg": "node --test test/integration/**/*.test.js",
43
+ "site:dev": "pnpm --dir site dev",
44
+ "site:build": "pnpm --dir site build",
45
+ "ship": "pnpm --dir site run ship"
46
+ }
47
+ }