Emmm Monster
4 years ago
8 changed files with 43 additions and 38 deletions
@ -1,16 +1,17 @@ |
|||||
import {GetArrayBuffer, SniffAudioExt} from "@/decrypt/utils.ts"; |
import {AudioMimeType, GetArrayBuffer, SniffAudioExt} from "@/decrypt/utils.ts"; |
||||
|
|
||||
const musicMetadata = require("music-metadata-browser"); |
|
||||
import {AudioMimeType, GetMetaCoverURL, GetFileInfo} from "./util"; |
|
||||
|
|
||||
export async function Decrypt(file, raw_filename, raw_ext, detect = true) { |
import {parseBlob as metaParseBlob} from "music-metadata-browser"; |
||||
|
import {GetMetaCoverURL, GetFileInfo} from "./util"; |
||||
|
|
||||
|
export async function Decrypt(file: Blob, raw_filename: string, raw_ext: string, detect: boolean = true) { |
||||
let ext = raw_ext; |
let ext = raw_ext; |
||||
if (detect) { |
if (detect) { |
||||
const buffer = new Uint8Array(await GetArrayBuffer(file)); |
const buffer = new Uint8Array(await GetArrayBuffer(file)); |
||||
ext = SniffAudioExt(buffer, raw_ext); |
ext = SniffAudioExt(buffer, raw_ext); |
||||
if (ext !== raw_ext) file = new Blob([buffer], {type: AudioMimeType[ext]}) |
if (ext !== raw_ext) file = new Blob([buffer], {type: AudioMimeType[ext]}) |
||||
} |
} |
||||
const tag = await musicMetadata.parseBlob(file); |
const tag = await metaParseBlob(file); |
||||
const info = GetFileInfo(tag.common.artist, tag.common.title, raw_filename); |
const info = GetFileInfo(tag.common.artist, tag.common.title, raw_filename); |
||||
return { |
return { |
||||
status: true, |
status: true, |
Loading…
Reference in new issue