From 23b01d5f87743c581768e3e5a27a656aa2d38324 Mon Sep 17 00:00:00 2001 From: MengYX Date: Sun, 5 Apr 2020 19:18:56 +0800 Subject: [PATCH] Fix GBK Encoding Reading in QQMusic Mp3 --- src/decrypt/qmc.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/decrypt/qmc.js b/src/decrypt/qmc.js index 6ec5a0f..e558ad3 100644 --- a/src/decrypt/qmc.js +++ b/src/decrypt/qmc.js @@ -1,6 +1,8 @@ import {AudioMimeType, DetectAudioExt, GetArrayBuffer, GetFileInfo, GetMetaCoverURL, RequestJsonp} from "./util"; import {QmcMaskCreate58, QmcMaskDetectMflac, QmcMaskDetectMgg, QmcMaskGetDefault} from "./qmcMask"; +import {decode} from "iconv-lite" + const musicMetadata = require("music-metadata-browser"); const HandlerMap = { @@ -40,8 +42,15 @@ export async function Decrypt(file, raw_filename, raw_ext) { let musicBlob = new Blob([musicDecoded], {type: mime}); const musicMeta = await musicMetadata.parseBlob(musicBlob); + let isGbk = musicMeta.native["ID3v2.3"] + .some(item => item.id === "TCON" && item.value === "(12)"); + if (isGbk) { + musicMeta.common.artist = decode(musicMeta.common.artist, "gbk"); + musicMeta.common.title = decode(musicMeta.common.title, "gbk"); + musicMeta.common.album = decode(musicMeta.common.album, "gbk"); + } + //todo: Use artists list to replace artist const info = GetFileInfo(musicMeta.common.artist, musicMeta.common.title, raw_filename); - if (handler.detect) reportKeyUsage(keyData, seed.Matrix128, info.artist, info.title, musicMeta.common.album, raw_filename, raw_ext);