1
0
forked from um/web

Add Support qq music cover

This commit is contained in:
MengYX 2020-07-18 21:45:53 +08:00
parent 59d47c755e
commit 438383979d
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604

View File

@ -1,18 +1,9 @@
import { import {AudioMimeType, DetectAudioExt, GetArrayBuffer, GetFileInfo, GetMetaCoverURL, GetWebImage} from "./util";
AudioMimeType,
DetectAudioExt,
GetArrayBuffer,
GetFileInfo,
GetMetaCoverURL,
GetWebImage,
RequestJsonp
} from "./util";
const MetaFlac = require('metaflac-js');
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 MetaFlac = require('metaflac-js');
const ID3Writer = require("browser-id3-writer"); const ID3Writer = require("browser-id3-writer");
const iconv = require('iconv-lite'); const iconv = require('iconv-lite');
@ -135,23 +126,21 @@ async function queryKeyInfo(keyData, filename, format) {
} }
async function queryAlbumCoverImage(artist, title, album) { async function queryAlbumCoverImage(artist, title, album) {
let song_query_url = "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?n=10&new_json=1&w=" + //https://stats.ixarea.com/collect
encodeURIComponent(artist + " " + title + " " + album); const song_query_url = "http://localhost:6580/music/qq-cover"
let jsonpData;
let queriedSong = undefined;
try { try {
jsonpData = await RequestJsonp(song_query_url, "callback"); const resp = await fetch(song_query_url, {
queriedSong = jsonpData["data"]["song"]["list"][0]; method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({Artist: artist, Title: title, Album: album}),
})
if (resp.ok) {
let data = await resp.json();
return song_query_url + "/" + data.Type + "/" + data.Id
}
} catch (e) { } catch (e) {
console.log(e) console.log(e);
} }
let imgUrl = ""; return "";
if (!!queriedSong && !!queriedSong["album"]) {
if (queriedSong["album"]["pmid"] !== undefined) {
imgUrl = "https://stats.ixarea.com/collect/music/qq-cover/1/" + queriedSong["album"]["pmid"]
} else if (queriedSong["album"]["id"] !== undefined) {
imgUrl = "https://stats.ixarea.com/collect/music/qq-cover/2/" + queriedSong["album"]["id"]
}
}
return imgUrl;
} }