123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- import axios from "axios";
- import he = require("he");
- const pageSize = 30;
- function validMusicFilter(_) {
- return `${_.pay_type}` === "0";
- }
- function formatMusicItem(_) {
- return {
- id: _.id,
- artwork: _.front_cover,
- title: _.soundstr,
- artist: _.username,
- user_id: _.user_id,
- duration: +(_.duration ?? 0),
- };
- }
- function formatAlbumItem(_) {
- return {
- id: _.id,
- artist: _.author,
- title: _.name,
- artwork: _.cover,
- description: _.abstract,
- };
- }
- const searchHeaders = {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: "https://www.missevan.com/sound/search",
- };
- async function searchMusic(query, page) {
- const res = (
- await axios.get("https://www.missevan.com/sound/getsearch", {
- params: {
- s: query,
- p: page,
- type: 3,
- page_size: pageSize,
- },
- headers: searchHeaders,
- })
- ).data.info;
- return {
- isEnd: res.pagination.p >= res.pagination.maxpage,
- data: res.Datas.filter(validMusicFilter).map(formatMusicItem),
- };
- }
- async function searchAlbum(query, page) {
- const res = (
- await axios.get("https://www.missevan.com/dramaapi/search", {
- headers: searchHeaders,
- params: {
- s: query,
- page,
- },
- })
- ).data.info;
- return {
- isEnd: res.pagination.p >= res.pagination.maxpage,
- data: res.Datas.filter(validMusicFilter).map(formatAlbumItem),
- };
- }
- async function getAlbumInfo(albumItem) {
- const res = (
- await axios.get("https://www.missevan.com/dramaapi/getdrama", {
- headers: {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: `https://www.missevan.com/mdrama/${albumItem.id}`,
- },
- params: {
- drama_id: albumItem.id,
- },
- })
- ).data;
- return {
- musicList: res.info.episodes.episode
- .filter(validMusicFilter)
- .map(_ => {
- const r = formatMusicItem(_);
- r.artwork = albumItem.artwork;
- return r;
- }),
- };
- }
- async function getMediaSource(musicItem, quality: IMusic.IQualityKey) {
- if (quality === "high" || quality === "super") {
- return;
- }
- const res = (
- await axios.get("https://www.missevan.com/sound/getsound", {
- headers: {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: `https://www.missevan.com/sound/player?id=${musicItem.id}`,
- },
- params: {
- soundid: musicItem.id,
- },
- })
- ).data.info;
- if (quality === "low") {
- return {
- url: res.sound.soundurl_128,
- };
- } else {
- return {
- url: res.sound.soundurl,
- };
- }
- }
- async function getRecommendSheetTags() {
- const res = (
- await axios.get(
- `https://www.missevan.com/malbum/recommand`,
- {
- headers: {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: `https://www.missevan.com`,
- }
- }
- )
- ).data.info;
- const data = Object.entries(res ?? {}).map(group => ({
- title: group[0],
- data: (group[1] as any).map(_ => ({
- id: _[0],
- title: _[1]
- }))
- }));
- return {
- data,
- };
- }
- async function getRecommendSheetsByTag(tag, page) {
- const res = (
- await axios.get(
- `https://www.missevan.com/explore/tagalbum`,
- {
- headers: {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: `https://m.missevan.com`,
- },
- params: {
- order: 0,
- tid: tag?.id || 0,
- p: page
- }
- }
- )
- ).data;
- return {
- isEnd: res.page >= res.maxpage,
- data: res.albums.map(sheet => ({
- id: sheet.id,
- title: sheet.title,
- artwork: sheet.front_cover,
- artist: sheet.username,
- createUserId: sheet.user_id
- }))
- }
- }
- async function getMusicSheetInfo(sheet: IMusicSheet.IMusicSheetItem, page) {
- const res = (
- await axios.get(
- `https://www.missevan.com/sound/soundalllist`,
- {
- headers: {
- "user-agent":
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.61",
- accept: "application/json",
- "accept-encoding": "gzip, deflate, br",
- referer: `https://m.missevan.com`,
- },
- params: {
- albumid: sheet.id
- }
- }
- )
- ).data.info;
- return {
- isEnd: true,
- musicList: res.sounds.filter(validMusicFilter).map(item => ({
- id: item.id,
- title: item.soundstr,
- artwork: item.front_cover,
- url: item.soundurl,
- artist: item.username,
- }))
- }
- }
- module.exports = {
- platform: "猫耳FM",
- author: '猫头猫',
- version: "0.1.4",
- appVersion: ">0.1.0-alpha.0",
- srcUrl:
- "https://gitee.com/maotoumao/MusicFreePlugins/raw/v0.1/dist/maoerfm/index.js",
- cacheControl: "no-cache",
- supportedSearchType: ["music", "album", ],
- async search(query, page, type) {
- if (type === "music") {
- return await searchMusic(query, page);
- }
- if (type === "album") {
- return await searchAlbum(query, page);
- }
- },
- getMediaSource,
- getAlbumInfo,
- getRecommendSheetTags,
- getRecommendSheetsByTag,
- getMusicSheetInfo
- };
|