代码拉取完成,页面将自动刷新
同步操作将从 猫头猫/MusicFreePlugins 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
function qianqian(packages) {
const { axios, dayjs, CryptoJs } = packages;
const pageSize = 20;
const secret = '0b50b02fd0d73a9c4c8c3a781c30845f';
function getSignedParams(e) {
if ("[object Object]" !== Object.prototype.toString.call(e))
throw new Error("The parameter of query must be a Object.");
var t = Math.floor(Date.now() / 1e3);
Object.assign(e, {
timestamp: t
});
var n = Object.keys(e);
n.sort();
for (var r = "", i = 0; i < n.length; i++) {
var s = n[i];
r += (0 == i ? "" : "&") + s + "=" + e[s]
}
return {
...e,
sign: CryptoJs.MD5(r += secret).toString(),
timestamp: t
}
}
const searchHeaders = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
'referer': 'https://music.91q.com/',
'from': 'web',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9'
};
function formatMusicItem(_) {
return {
id: _.id || _.assetId,
artwork: _.pic,
title: _.title,
artist: (_.artist || []).map(ar => ar.name).join('、'),
artistItems: (_.artist || []).map(formatArtistItem),
album: _.albumTitle,
lrc: _.lyric
}
}
function formatAlbumItem(_) {
return {
id: _.albumAssetCode,
artist: (_.artist || []).map(ar => ar.name).join('、'),
title: _.title,
artwork: _.pic,
description: '',
date: dayjs(_.releaseDate).format('YYYY-MM-DD'),
}
}
function formatArtistItem(_) {
return {
name: _.name,
id: _.artistCode,
avatar: _.pic,
worksNum: _.trackTotal,
description: _.introduce,
}
}
function musicCanPlayFilter(_) {
return !_.pay_model;
}
async function searchBase(query, page, type) {
const res = (await axios.get('https://music.91q.com/v1/search', {
headers: searchHeaders,
params: getSignedParams({
appid: '16073360',
type,
word: query,
pageNo: page,
pageSize
})
}));
return res.data;
}
async function searchMusic(query, page) {
const res = await searchBase(query, page, 1);
return {
isEnd: res.data.total <= page * pageSize,
data: res.data.typeTrack.filter(musicCanPlayFilter).map(formatMusicItem)
}
}
async function searchAlbum(query, page) {
const res = await searchBase(query, page, 3);
return {
isEnd: res.data.total <= page * pageSize,
data: res.data.typeAlbum.map(formatAlbumItem)
}
}
async function searchArtist(query, page) {
const res = await searchBase(query, page, 2);
return {
isEnd: res.data.total <= page * pageSize,
data: res.data.typeArtist.map(formatArtistItem)
}
}
async function getArtistMusicWorks(artistItem, page) {
const headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
'referer': `https://music.91q.com/search?word=${encodeURIComponent(artistItem.name)}`,
'from': 'web',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9'
};
const res = (await axios.get('https://music.91q.com/v1/artist/song', {
headers,
params: getSignedParams({
appid: '16073360',
artistCode: artistItem.id,
pageNo: page,
pageSize
})
})).data;
return {
isEnd: res.data.total <= page * pageSize,
data: res.data.result.filter(musicCanPlayFilter).map(formatMusicItem)
}
}
async function getArtistAlbumWorks(artistItem, page) {
const headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
'referer': `https://music.91q.com/search?word=${encodeURIComponent(artistItem.name)}`,
'from': 'web',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9'
};
const res = (await axios.get('https://music.91q.com/v1/artist/album', {
headers,
params: getSignedParams({
appid: '16073360',
artistCode: artistItem.id,
pageNo: page,
pageSize
})
})).data;
return {
isEnd: res.data.total <= page * pageSize,
data: res.data.result.map(formatAlbumItem)
}
}
async function getArtistWorks(artistItem, page, type) {
if (type === 'music') {
return getArtistMusicWorks(artistItem, page);
} else if (type === 'album') {
return getArtistAlbumWorks(artistItem, page);
}
}
async function getLyric(musicItem) {
return {
lrc: musicItem.lrc
}
}
async function getAlbumInfo(albumItem) {
if (albumItem.musicList) {
return albumItem;
} else {
const headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
'referer': `https://music.91q.com/search?word=${encodeURIComponent(albumItem.name)}`,
'from': 'web',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9'
};
const res = (await axios.get('https://music.91q.com/v1/album/info', {
headers,
params: getSignedParams({
appid: '16073360',
albumAssetCode: albumItem.id,
})
}));
const musicList = (res.data.data.trackList || []).filter(musicCanPlayFilter).map(_ => ({
...formatMusicItem(_),
artwork: albumItem.artwork,
album: albumItem.name
}))
return {
...albumItem,
musicList
}
}
}
return {
platform: '千千音乐',
version: '0.0.0',
srcUrl: 'https://gitee.com/maotoumao/MusicFreePlugins/raw/master/qianqian.js',
cacheControl: 'no-cache',
async search(query, page, type) {
if (type === 'music') {
return await searchMusic(query, page);
}
if (type === 'album') {
return await searchAlbum(query, page);
}
if (type === 'artist') {
return await searchArtist(query, page);
}
},
async getMediaSource(musicItem) {
const headers = {
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
'referer': `https://music.91q.com/artist/${(musicItem.artistItems[0] || {}).id}`,
'from': 'webapp_music',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'zh-CN,zh;q=0.9'
}
const res = (await axios.get('https://music.91q.com/v1/song/tracklink', {
headers,
params: getSignedParams({
appid: '16073360',
TSID: musicItem.id,
})
})).data;
return {
url: res.data.path
};
},
getAlbumInfo,
getLyric,
getArtistWorks
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。