Browse Source

Resolve QQMusic Cover(By IXarea Server)

20230320
MengYX 4 years ago
parent
commit
6b1c08663a
No known key found for this signature in database GPG Key ID: E63F9C7303E8F604
  1. 9
      src/decrypt/kwm.js
  2. 36
      src/decrypt/qmc.js

9
src/decrypt/kwm.js

@ -1,11 +1,4 @@
import { import {AudioMimeType, DetectAudioExt, GetArrayBuffer, GetFileInfo, GetMetaCoverURL, IsBytesEqual} from "./util";
AudioMimeType,
DetectAudioExt,
GetArrayBuffer,
GetFileInfo,
GetMetaCoverURL,
IsBytesEqual
} from "./util";
const musicMetadata = require("music-metadata-browser"); const musicMetadata = require("music-metadata-browser");
const MagicHeader = [ const MagicHeader = [

36
src/decrypt/qmc.js

@ -1,8 +1,19 @@
import {AudioMimeType, DetectAudioExt, GetArrayBuffer, GetFileInfo, GetMetaCoverURL, RequestJsonp} from "./util"; import {
AudioMimeType,
DetectAudioExt,
GetArrayBuffer,
GetFileInfo,
GetMetaCoverURL,
GetWebImage,
RequestJsonp
} from "./util";
import {QmcMaskCreate58, QmcMaskDetectMflac, QmcMaskDetectMgg, QmcMaskGetDefault} from "./qmcMask"; import {QmcMaskCreate58, QmcMaskDetectMflac, QmcMaskDetectMgg, QmcMaskGetDefault} from "./qmcMask";
import {fromByteArray as Base64Encode, toByteArray as Base64Decode} from 'base64-js'
const ID3Writer = require("browser-id3-writer");
import {fromByteArray as Base64Encode, toByteArray as Base64Decode} from 'base64-js' const iconv = require('iconv-lite');
const decode = iconv.decode
const musicMetadata = require("music-metadata-browser"); const musicMetadata = require("music-metadata-browser");
@ -60,7 +71,21 @@ export async function Decrypt(file, raw_filename, raw_ext) {
let imgUrl = GetMetaCoverURL(musicMeta); let imgUrl = GetMetaCoverURL(musicMeta);
if (imgUrl === "") { if (imgUrl === "") {
imgUrl = await queryAlbumCoverImage(info.artist, info.title, musicMeta.common.album); imgUrl = await queryAlbumCoverImage(info.artist, info.title, musicMeta.common.album);
//todo: 解决跨域获取图像的问题 if (imgUrl !== "") {
const imageInfo = await GetWebImage(imgUrl);
if (imageInfo.url !== "") {
imgUrl = imageInfo.url
if (ext === "mp3") {
let writer = new ID3Writer(audioData)
writer.setFrame('APIC', {
type: 3,
data: imageInfo.buffer,
description: "Cover",
})
musicBlob = new Blob([musicDecoded], {type: mime});
}
}
}
} }
return { return {
status: true, status: true,
@ -112,10 +137,9 @@ async function queryAlbumCoverImage(artist, title, album) {
let imgUrl = ""; let imgUrl = "";
if (!!queriedSong && !!queriedSong["album"]) { if (!!queriedSong && !!queriedSong["album"]) {
if (queriedSong["album"]["pmid"] !== undefined) { if (queriedSong["album"]["pmid"] !== undefined) {
imgUrl = "https://y.gtimg.cn/music/photo_new/T002M000" + queriedSong["album"]["pmid"] + ".jpg" imgUrl = "https://stats.ixarea.com/collect/qq-cover/1/" + queriedSong["album"]["pmid"]
} else if (queriedSong["album"]["id"] !== undefined) { } else if (queriedSong["album"]["id"] !== undefined) {
imgUrl = "https://imgcache.qq.com/music/photo/album/" + imgUrl = "https://stats.ixarea.com/collect/music/qq-cover/2/" + queriedSong["album"]["id"]
queriedSong["album"]["id"] % 100 + "/albumpic_" + queriedSong["album"]["id"] + "_0.jpg"
} }
} }
return imgUrl; return imgUrl;

Loading…
Cancel
Save