Resolve QQMusic Cover(By IXarea Server)

This commit is contained in:
MengYX 2020-07-17 00:33:10 +08:00
parent c338b6ef04
commit 6b1c08663a
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
2 changed files with 32 additions and 15 deletions

View File

@ -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 = [

View File

@ -1,9 +1,20 @@
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' import {fromByteArray as Base64Encode, toByteArray as Base64Decode} from 'base64-js'
const ID3Writer = require("browser-id3-writer");
const iconv = require('iconv-lite');
const decode = iconv.decode
const musicMetadata = require("music-metadata-browser"); const musicMetadata = require("music-metadata-browser");
const HandlerMap = { const HandlerMap = {
@ -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;