MengYX
5 years ago
8 changed files with 33 additions and 50 deletions
@ -1,19 +1,17 @@ |
|||||
const musicMetadata = require("music-metadata-browser"); |
const musicMetadata = require("music-metadata-browser"); |
||||
const util = require("./util"); |
import {GetCoverURL, GetFileInfo, AudioMimeType} from "./util"; |
||||
export {Decrypt} |
|
||||
|
|
||||
|
export async function Decrypt(file, raw_filename, raw_ext) { |
||||
async function Decrypt(file, raw_filename, raw_ext) { |
|
||||
const tag = await musicMetadata.parseBlob(file); |
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 { |
return { |
||||
status: true, |
status: true, |
||||
title: info.title, |
title: info.title, |
||||
artist: info.artist, |
artist: info.artist, |
||||
ext: raw_ext, |
ext: raw_ext, |
||||
album: tag.common.album, |
album: tag.common.album, |
||||
picture: util.GetCoverURL(tag), |
picture: GetCoverURL(tag), |
||||
file: URL.createObjectURL(file), |
file: URL.createObjectURL(file), |
||||
mime: util.AudioMimeType[raw_ext] |
mime: AudioMimeType[raw_ext] |
||||
} |
} |
||||
} |
} |
||||
|
@ -1,14 +1,14 @@ |
|||||
const rawDecrypt = require("./raw"); |
import {Decrypt as RawDecrypt} from "./raw"; |
||||
const util = require("./util"); |
import {GetArrayBuffer} from "./util"; |
||||
export {Decrypt} |
|
||||
const header = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70]; |
|
||||
|
|
||||
async function Decrypt(file, raw_filename) { |
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70]; |
||||
const fileBuffer = await util.GetArrayBuffer(file); |
|
||||
|
export async function Decrypt(file, raw_filename) { |
||||
|
const fileBuffer = await GetArrayBuffer(file); |
||||
const audioData = new Uint8Array(fileBuffer); |
const audioData = new Uint8Array(fileBuffer); |
||||
for (let cur = 0; cur < 8; ++cur) { |
for (let cur = 0; cur < 8; ++cur) { |
||||
audioData[cur] = header[cur]; |
audioData[cur] = TM_HEADER[cur]; |
||||
} |
} |
||||
const musicData = new Blob([audioData], {type: "audio/mp4"}); |
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