Replace deprecated jsmediatags with music-metadata (#42)

Co-authored-by: Borewit <Borewit@users.noreply.github.com>
This commit is contained in:
Borewit 2025-03-06 20:45:19 +01:00 committed by GitHub
parent 06ec2f1a11
commit a47e6f973f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 821 additions and 3399 deletions

4175
bun.lock

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@
"@sveltejs/kit": "^2.16.0", "@sveltejs/kit": "^2.16.0",
"@sveltejs/vite-plugin-svelte": "^4.0.4", "@sveltejs/vite-plugin-svelte": "^4.0.4",
"@types/eslint": "^9.6.1", "@types/eslint": "^9.6.1",
"@types/jsmediatags": "^3.9.6",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"eslint": "^9.18.0", "eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1", "eslint-config-prettier": "^10.0.1",
@ -43,12 +42,9 @@
"@imagemagick/magick-wasm": "^0.0.32", "@imagemagick/magick-wasm": "^0.0.32",
"client-zip": "^2.4.6", "client-zip": "^2.4.6",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"jsmediatags": "^3.9.7",
"lucide-svelte": "^0.475.0", "lucide-svelte": "^0.475.0",
"music-metadata": "^11.0.0",
"vite-plugin-static-copy": "^2.2.0", "vite-plugin-static-copy": "^2.2.0",
"wasm-vips": "^0.0.11" "wasm-vips": "^0.0.11"
},
"patchedDependencies": {
"jsmediatags@3.9.7": "patches/jsmediatags@3.9.7.patch"
} }
} }

View File

@ -1,15 +0,0 @@
diff --git a/package.json b/package.json
index 1265c61a16be5dc94dea97e1a7bcd117b0b5c0fe..602a37452738d778bf705b7a2931a661e363e33c 100644
--- a/package.json
+++ b/package.json
@@ -18,8 +18,8 @@
"email": "jesse.ditson@gmail.com"
}
],
- "main": "build2/jsmediatags.js",
- "browser": "dist/jsmediatags.js",
+ "main": "dist/jsmediatags.min.js",
+ "browser": "dist/jsmediatags.min.js",
"repository": {
"type": "git",
"url": "git+https://github.com/aadsm/jsmediatags.git"

View File

@ -1,8 +1,7 @@
import { converters } from "$lib/converters"; import { converters } from "$lib/converters";
import { error, log } from "$lib/logger"; import { error, log } from "$lib/logger";
import { VertFile } from "$lib/types"; import { VertFile } from "$lib/types";
import jsmediatags from "jsmediatags"; import { parseBlob, selectCover } from "music-metadata";
import type { TagType } from "jsmediatags/types";
import { writable } from "svelte/store"; import { writable } from "svelte/store";
import { addDialog } from "./DialogProvider"; import { addDialog } from "./DialogProvider";
@ -33,22 +32,17 @@ class Files {
try { try {
if (isAudio) { if (isAudio) {
// try to get the thumbnail from the audio via jsmmediatags // try to get the thumbnail from the audio via music-metadata
const tags = await new Promise<TagType>((resolve, reject) => { const {common} = await parseBlob(file.file);
jsmediatags.read(file.file, { const cover = selectCover(common.picture);
onSuccess: (tag) => resolve(tag), if (cover) {
onError: (error) => reject(error),
});
});
if (tags.tags.picture) {
const blob = new Blob( const blob = new Blob(
[new Uint8Array(tags.tags.picture.data)], [cover.data],
{ {
type: tags.tags.picture.format, type: cover.format,
}, },
); );
const url = URL.createObjectURL(blob); file.blobUrl = URL.createObjectURL(blob);
file.blobUrl = url;
} }
} else if (isVideo) { } else if (isVideo) {
// video // video