mirror of
https://git.um-react.app/um/um-react.git
synced 2026-08-30 05:02:02 +00:00
Dependency upgrade + lib_um_crypto_rust (#78)
Co-authored-by: 鲁树人 <[email protected]> Co-committed-by: 鲁树人 <[email protected]>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { FetchMusicExNamePayload, ParseKuwoHeaderResponse } from '~/decrypt-worker/types.ts';
|
||||
import { KuwoHeader } from '@unlock-music/crypto';
|
||||
|
||||
export const workerParseKuwoHeader = async ({ blobURI }: FetchMusicExNamePayload): Promise<ParseKuwoHeaderResponse> => {
|
||||
const blob = await fetch(blobURI, { headers: { Range: 'bytes=0-1023' } }).then((r) => r.blob());
|
||||
const arrayBuffer = await blob.arrayBuffer();
|
||||
|
||||
try {
|
||||
const buffer = new Uint8Array(arrayBuffer.slice(0, 1024));
|
||||
const kwm = KuwoHeader.parse(buffer);
|
||||
const { qualityId, resourceId } = kwm;
|
||||
kwm.free();
|
||||
return { qualityId, resourceId };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user