MyFreeMP3 API

Music API for http://tool.liumingye.cn/music/ and http://tool.liumingye.cn/music_old/

目前為 2023-08-27 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/474021/1241708/MyFreeMP3%20API.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
PYUDNG
版本
0.1
建立日期
2023-08-27
更新日期
2023-08-27
尺寸
14.2 KB
授權條款
MIT

Music API for MyFreeMP3 and MyFreeMP3(old)

Requirements:

//@grant GM_xmlhttpRequest
//@connect api.liumingye.cn
//@connect api2.liumingye.cn

Usage: This method will request new or old api and provides a standardized callback argument object. Recommended.

Mfapi.search({
    type: 'YQD', // Search songs in "M" then use "YQM", search songs in "B" then use "YQB", search songs in "D" then use "YQD", etc
    text: 'your search params', // Song name, artist names, etc
    page: 1, // Default: 1
    callback: function(json) { console.log(json); },
    onerror: function(err) { console.log(err); }, // Default: function() {}
    api: 'auto' // Which api to use, 'new','old' or 'auto' for automatically choose, Default: 'auto'
}, 3);
// The second argument is retry count,  meaning how many retries we'll take before onerror got called.
// This number will be doubled if your api === 'auto' because we have to try both new and old apis if one of them is unavailable.
// Default: 3

or you can request old or new api directly to access raw api return value.

Mfapi.new.search({ type, text, page, callback, onerror });
Mfapi.old.search({ type, text, page, callback, onerror });

The apis' token encoders are also provided as Mfapi.new.encode and Mfapi.old.encode, and there's also Mfapi.new.link and Mfapi.old.link methods which accepts a song object and a quality number and returns its download url.

Try it out yourself and look into the callback values!