Optimize Import
parent
41a45176be
commit
10f09958c4
@ -1,19 +1,17 @@
|
||||
const musicMetadata = require("music-metadata-browser");
|
||||
const util = require("./util");
|
||||
export {Decrypt}
|
||||
import {GetCoverURL, GetFileInfo, AudioMimeType} from "./util";
|
||||
|
||||
|
||||
async function Decrypt(file, raw_filename, raw_ext) {
|
||||
export async function Decrypt(file, raw_filename, raw_ext) {
|
||||
const tag = await musicMetadata.parseBlob(file);
|
||||
const info = util.GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
|
||||
const info = GetFileInfo(tag.common.artist, tag.common.title, raw_filename);
|
||||
return {
|
||||
status: true,
|
||||
title: info.title,
|
||||
artist: info.artist,
|
||||
ext: raw_ext,
|
||||
album: tag.common.album,
|
||||
picture: util.GetCoverURL(tag),
|
||||
picture: GetCoverURL(tag),
|
||||
file: URL.createObjectURL(file),
|
||||
mime: util.AudioMimeType[raw_ext]
|
||||
mime: AudioMimeType[raw_ext]
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
const rawDecrypt = require("./raw");
|
||||
const util = require("./util");
|
||||
export {Decrypt}
|
||||
const header = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
|
||||
import {Decrypt as RawDecrypt} from "./raw";
|
||||
import {GetArrayBuffer} from "./util";
|
||||
|
||||
async function Decrypt(file, raw_filename) {
|
||||
const fileBuffer = await util.GetArrayBuffer(file);
|
||||
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
|
||||
|
||||
export async function Decrypt(file, raw_filename) {
|
||||
const fileBuffer = await GetArrayBuffer(file);
|
||||
const audioData = new Uint8Array(fileBuffer);
|
||||
for (let cur = 0; cur < 8; ++cur) {
|
||||
audioData[cur] = header[cur];
|
||||
audioData[cur] = TM_HEADER[cur];
|
||||
}
|
||||
const musicData = new Blob([audioData], {type: "audio/mp4"});
|
||||
return await rawDecrypt.Decrypt(musicData, raw_filename, "m4a")
|
||||
return await RawDecrypt(musicData, raw_filename, "m4a")
|
||||
}
|
||||
|
Loading…
Reference in New Issue