forked from um/web
feat(joox): re-use QM meta extraction code
(cherry picked from commit 2e946e6e30e02085018e868b7857acb62a1a0b08)
This commit is contained in:
parent
85544cd09a
commit
a69ed4f3ce
@ -1,9 +1,11 @@
|
|||||||
|
import jooxFactory from '@unlock-music/joox-crypto';
|
||||||
|
|
||||||
import { DecryptResult } from './entity';
|
import { DecryptResult } from './entity';
|
||||||
import { AudioMimeType, GetArrayBuffer, SniffAudioExt } from './utils';
|
import { AudioMimeType, GetArrayBuffer, SniffAudioExt } from './utils';
|
||||||
|
|
||||||
import jooxFactory from '@unlock-music/joox-crypto';
|
|
||||||
import { MergeUint8Array } from '@/utils/MergeUint8Array';
|
import { MergeUint8Array } from '@/utils/MergeUint8Array';
|
||||||
import { storage } from '@/utils/storage';
|
import { storage } from '@/utils/storage';
|
||||||
|
import { extractQQMusicMeta } from '@/utils/qm_meta';
|
||||||
|
|
||||||
export async function Decrypt(file: Blob, raw_filename: string, raw_ext: string): Promise<DecryptResult> {
|
export async function Decrypt(file: Blob, raw_filename: string, raw_ext: string): Promise<DecryptResult> {
|
||||||
const uuid = await storage.loadJooxUUID('');
|
const uuid = await storage.loadJooxUUID('');
|
||||||
@ -20,15 +22,21 @@ export async function Decrypt(file: Blob, raw_filename: string, raw_ext: string)
|
|||||||
const musicDecoded = MergeUint8Array(decryptor.decryptFile(fileBuffer));
|
const musicDecoded = MergeUint8Array(decryptor.decryptFile(fileBuffer));
|
||||||
const ext = SniffAudioExt(musicDecoded);
|
const ext = SniffAudioExt(musicDecoded);
|
||||||
const mime = AudioMimeType[ext];
|
const mime = AudioMimeType[ext];
|
||||||
const musicBlob = new Blob([musicDecoded], { type: mime });
|
|
||||||
|
const { album, artist, imgUrl, blob, title } = await extractQQMusicMeta(
|
||||||
|
new Blob([musicDecoded], { type: mime }),
|
||||||
|
raw_filename,
|
||||||
|
ext,
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: raw_filename.replace(/\.[^\.]+$/, ''),
|
title: title,
|
||||||
artist: '未知',
|
artist: artist,
|
||||||
album: '未知',
|
|
||||||
file: URL.createObjectURL(musicBlob),
|
|
||||||
blob: musicBlob,
|
|
||||||
mime: mime,
|
|
||||||
ext: ext,
|
ext: ext,
|
||||||
|
album: album,
|
||||||
|
picture: imgUrl,
|
||||||
|
file: URL.createObjectURL(blob),
|
||||||
|
blob: blob,
|
||||||
|
mime: mime,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user