Feat: Netease Music API Alias

网易云 API 增加别名字段,部分参数更正,文档说明内容更正
This commit is contained in:
2022-04-13 23:55:58 +08:00
parent ec6dd8873f
commit 46a5db6f4b
7 changed files with 105 additions and 92 deletions
+1
View File
@@ -31,6 +31,7 @@ export default Api(
} }
} }
// 直接播放
if ("play" in ctx.query) { if ("play" in ctx.query) {
ctx.status = 302; ctx.status = 302;
ctx.set("location", `https://music.163.com/song/media/outer/url?id=${id}`); ctx.set("location", `https://music.163.com/song/media/outer/url?id=${id}`);
+23 -6
View File
@@ -6,7 +6,7 @@ import { client } from './utils/redis';
export default Api( export default Api(
Get(), Get(),
Query<{ id?: string }>(), Query<{ id?: string, play?: string }>(),
async () => { async () => {
const ctx = useContext(); const ctx = useContext();
@@ -15,6 +15,21 @@ export default Api(
const { id } = ctx.query; const { id } = ctx.query;
if (!id) {
return {
code: 0,
msg: "Failed, no id found"
}
}
// 直接播放
if ("play" in ctx.query) {
ctx.status = 302;
ctx.set("location", `https://music.163.com/song/media/outer/url?id=${id}`);
return "";
}
// 尝试使用缓存 // 尝试使用缓存
const cached = await client.lRange(`api-next:163:${id}`, 0, 7); const cached = await client.lRange(`api-next:163:${id}`, 0, 7);
@@ -27,11 +42,12 @@ export default Api(
title: cached[0], title: cached[0],
artist: cached[1], artist: cached[1],
album: cached[2], album: cached[2],
cover: cached[3], alias: cached[3],
lyric: cached[4], cover: cached[4],
sub_lyric: cached[5], lyric: cached[5],
link: cached[6], sub_lyric: cached[6],
served: Boolean(cached[7]), link: cached[7],
served: Boolean(cached[8]),
cached: true cached: true
} }
}; };
@@ -45,6 +61,7 @@ export default Api(
song.title, song.title,
song.artist, song.artist,
song.album, song.album,
song.alias,
song.cover, song.cover,
song.lyric, song.lyric,
song.sub_lyric, song.sub_lyric,
+1
View File
@@ -46,6 +46,7 @@ export const parseSongData = async (item: any) => {
id: item.id, id: item.id,
title: item.name, title: item.name,
artist: item.artists ?. [0].name || "", artist: item.artists ?. [0].name || "",
alias: item.alias ?. [0] || "",
album: item.album.name || "", album: item.album.name || "",
cover: `${item.album.picUrl.replace("http://", "https://")}?param=250y250"`, cover: `${item.album.picUrl.replace("http://", "https://")}?param=250y250"`,
lyric, lyric,
+48 -13
View File
@@ -54,7 +54,7 @@ function ACGM() {
<ArticleHead title="随机动漫音乐" desc="输出一首随机的动漫音乐及信息,基于网易云 API" /> <ArticleHead title="随机动漫音乐" desc="输出一首随机的动漫音乐及信息,基于网易云 API" />
<article className="post"> <article className="post">
<h3>使用方法:</h3> <h3>使用方法:</h3>
<p>调用地址 <code>https://api.paugram.com/acgm/</code>,即可获得一段歌曲 <code>JSON</code> 信息。</p> <p>调用地址 <code>https://api.paugram.com/api/acgm</code>,即可获得一段歌曲 <code>JSON</code> 信息。</p>
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p> <p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
<p>音乐版权归网易云音乐所有,本站不为滥用本 API 进行违规操作者承担责任。部分歌曲可能因版权问题无法播放,敬请谅解!</p> <p>音乐版权归网易云音乐所有,本站不为滥用本 API 进行违规操作者承担责任。部分歌曲可能因版权问题无法播放,敬请谅解!</p>
<p>为了防止多次出现随机到同一首歌的情况,请允许我们使用你的 <code>Cookie</code> 记录。</p> <p>为了防止多次出现随机到同一首歌的情况,请允许我们使用你的 <code>Cookie</code> 记录。</p>
@@ -71,7 +71,7 @@ function ACGM() {
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>list</td> <td>list(施工中)</td>
<td>可选的音乐列表 <code>详见下方</code>,默认 <code>随机</code></td> <td>可选的音乐列表 <code>详见下方</code>,默认 <code>随机</code></td>
<td>音乐类别</td> <td>音乐类别</td>
</tr> </tr>
@@ -116,32 +116,59 @@ function ACGM() {
<tr> <tr>
<td>参数名称</td> <td>参数名称</td>
<td>描述</td> <td>描述</td>
<td>值</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>id</td> <td>id</td>
<td>音乐 ID</td> <td>音乐 ID</td>
<td><code>string</code></td>
</tr> </tr>
<tr> <tr>
<td>title</td> <td>title</td>
<td>音乐名称</td> <td>音乐名称</td>
<td><code>string</code></td>
</tr> </tr>
<tr> <tr>
<td>artist</td> <td>artist</td>
<td>音乐艺术家</td> <td>音乐艺术家</td>
<td><code>string</code></td>
</tr> </tr>
<tr> <tr>
<td>album</td> <td>album</td>
<td>音乐专辑名称</td> <td>音乐专辑名称</td>
<td><code>string</code></td>
</tr>
<tr>
<td>alias</td>
<td>音乐别称</td>
<td><code>string</code></td>
</tr> </tr>
<tr> <tr>
<td>cover</td> <td>cover</td>
<td>音乐专辑图片(https)</td> <td>音乐专辑图片链接(https)</td>
<td><code>string</code></td>
</tr> </tr>
<tr> <tr>
<td>link</td> <td>link</td>
<td>音乐源地址(https)</td> <td>音乐源地址链接</td>
<td><code>string</code></td>
</tr>
<tr>
<td>lyric</td>
<td>音乐 LRC 歌词内容</td>
<td><code>string</code></td>
</tr>
<tr>
<td>sub_lyric</td>
<td>翻译版 LRC 歌词内容(如果有)</td>
<td><code>string</code></td>
</tr>
<tr>
<td>served</td>
<td>是否为 VIP 或无版权歌曲(测试功能)</td>
<td><code>true</code> <code>false</code></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -149,23 +176,31 @@ function ACGM() {
<h3>示例:</h3> <h3>示例:</h3>
<p>获得一首随机动漫音乐的信息</p> <p>获得一首随机动漫音乐的信息</p>
<pre className="language-javascript"><code>{`https://api.paugram.com/acgm/ <pre className="language-javascript"><code>{`https://api.paugram.com/api/acgm
// 返回的是: // 返回的是:
{ {
"id": 517567145, "code": 1,
"title": "初登校", "msg": "Success",
"artist": "橋本由香利", "data": {
"album": "ひなこのーと COMPLETE SOUNDTRACK", "id": 435289265,
"cover": 封面地址, "title": "問題がある人たち",
"link": 音乐地址 "artist": "吟",
"alias": "",
"album": "この美術部には問題がある! オリジナルサウンドトラックCD vol.1",
"cover": "封面地址",
"lyric": "歌词内容",
"sub_lyric": "翻译歌词内容",
"link": "音乐地址",
"served": false
}
} }
`}</code></pre> `}</code></pre>
<p>通过 <code>List</code> 获得一首随机动漫歌曲的信息,并跳转到实际地址</p> <p>通过 <code>List</code> 获得一首随机动漫歌曲的信息,并跳转到实际地址</p>
<pre><code>https://api.paugram.com/acgm/?list=1&play=true</code></pre> <pre><code>https://api.paugram.com/api/acgm/?list=1&play=true</code></pre>
<p>建立一个 <code>Audio</code> 播放器,并使用本 API</p> <p>建立一个 <code>Audio</code> 播放器,并使用本 API</p>
<pre className="language-html"><code>&lt;audio src="https://api.paugram.com/acgm/?play=true" controls&gt;&lt;/audio&gt;</code></pre> <pre className="language-html"><code>&lt;audio src="https://api.paugram.com/api/acgm/?play=true" controls&gt;&lt;/audio&gt;</code></pre>
<h3>测试小工具:</h3> <h3>测试小工具:</h3>
<p>来一首随机动漫音乐吧!刷新或点击按钮即可切歌</p> <p>来一首随机动漫音乐吧!刷新或点击按钮即可切歌</p>
+5 -5
View File
@@ -18,7 +18,7 @@ function Bing() {
<ArticleHead title="必应每日壁纸" desc="每日更新,尽享乐趣" /> <ArticleHead title="必应每日壁纸" desc="每日更新,尽享乐趣" />
<article className="post"> <article className="post">
<h3>使用方法:</h3> <h3>使用方法:</h3>
<p>调用地址 <code>https://api.paugram.com/bing/</code> 可自动跳转到对应的壁纸</p> <p>调用地址 <code>https://api.paugram.com/api/bing</code> 可自动跳转到对应的壁纸</p>
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p> <p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
<p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p> <p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p>
@@ -42,9 +42,9 @@ function Bing() {
<h3>示例:</h3> <h3>示例:</h3>
<p>调用一张当天的图片</p> <p>调用一张当天的图片</p>
<pre><code>https://api.paugram.com/bing</code></pre> <pre><code>https://api.paugram.com/api/bing</code></pre>
<p>调用一张当天的图片,并使用 JSON 形式返回资料</p> <p>调用一张当天的图片,并使用 JSON 形式返回资料</p>
<pre className="language-javascript"><code>{`https://api.paugram.com/bing/?info <pre className="language-javascript"><code>{`https://api.paugram.com/api/bing/?info
// 返回的是: // 返回的是:
@@ -54,7 +54,7 @@ function Bing() {
}`}</code></pre> }`}</code></pre>
<p>在网页背景上使用本 API</p> <p>在网页背景上使用本 API</p>
<pre className="language-css"><code>{`body{ <pre className="language-css"><code>{`body{
background: url("https://api.paugram.com/bing/") center/cover no-repeat; background: url("https://api.paugram.com/api/bing") center/cover no-repeat;
}`} }`}
</code></pre> </code></pre>
<p>在网页背景上使用本 API(伪元素半透明版)</p> <p>在网页背景上使用本 API(伪元素半透明版)</p>
@@ -67,7 +67,7 @@ function Bing() {
z-index: -1; z-index: -1;
content: ""; content: "";
position: fixed; position: fixed;
background: url(https://api.paugram.com/bing/) center/cover; background: url(https://api.paugram.com/api/bing) center/cover;
}`} }`}
</code></pre> </code></pre>
+17 -16
View File
@@ -18,12 +18,11 @@ function Netease() {
<ArticleHead title="网易云解析" desc="解析音乐并精简输出,配合 Kico Player 使用更佳" /> <ArticleHead title="网易云解析" desc="解析音乐并精简输出,配合 Kico Player 使用更佳" />
<article className="post"> <article className="post">
<h3>使用方法:</h3> <h3>使用方法:</h3>
<p>调用地址 <code>https://api.paugram.com/netease/</code> 并输入参数 <code>id</code> 或 <code>title</code>,即可获得一段歌曲 <code>JSON</code> 信息。</p> <p>调用地址 <code>https://api.paugram.com/netease</code> 并输入参数 <code>id</code> 或 <code>title</code>,即可获得一段歌曲 <code>JSON</code> 信息。</p>
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p> <p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
<p>音乐版权归网易云音乐所有,本站不为滥用本 API 进行违规操作者承担责任。</p> <p>音乐版权归网易云音乐所有,本站不为滥用本 API 进行违规操作者承担责任。</p>
<h3>参数:</h3> <h3>参数:</h3>
<p>建议使用 <code>id</code> 的方式获得歌曲信息,性能相对较好。</p>
<div className="ks-table text-nowrap"> <div className="ks-table text-nowrap">
<table> <table>
<thead> <thead>
@@ -39,11 +38,6 @@ function Netease() {
<td>有效的音乐 ID,例:<code>517567145</code></td> <td>有效的音乐 ID,例:<code>517567145</code></td>
<td>音乐 ID</td> <td>音乐 ID</td>
</tr> </tr>
<tr>
<td>playlist(施工中)</td>
<td>有多首音乐的音乐列表</td>
<td>音乐列表</td>
</tr>
<tr> <tr>
<td>play</td> <td>play</td>
<td>参数值为 <code>true</code> 则启用跳转</td> <td>参数值为 <code>true</code> 则启用跳转</td>
@@ -84,6 +78,11 @@ function Netease() {
<td>音乐专辑名称</td> <td>音乐专辑名称</td>
<td><code>string</code></td> <td><code>string</code></td>
</tr> </tr>
<tr>
<td>alias</td>
<td>音乐别称</td>
<td><code>string</code></td>
</tr>
<tr> <tr>
<td>cover</td> <td>cover</td>
<td>音乐专辑图片链接(https)</td> <td>音乐专辑图片链接(https)</td>
@@ -115,7 +114,7 @@ function Netease() {
<h3>示例:</h3> <h3>示例:</h3>
<p>通过 ID 获得一首歌的信息</p> <p>通过 ID 获得一首歌的信息</p>
<pre className="language-javascript"><code>{`https://api.paugram.com/netease/?id=517567145 <pre className="language-javascript"><code>{`https://api.paugram.com/netease/?id=448143347
// 返回的是: // 返回的是:
@@ -123,14 +122,16 @@ function Netease() {
"code": 1, "code": 1,
"msg": "Success", "msg": "Success",
"data": { "data": {
"id": 517567145, "id": 448143347,
"title": "初登校", "title": "STARTING NOW!",
"artist": "橋本由香利", "artist": "水樹奈々",
"album": "ひなこのーと COMPLETE SOUNDTRACK", "album": "NEOGENE CREATION",
"cover": 封面地址, "alias": "TV动画《这个美术社大有问题!》片头曲",
"lyric": 歌词内容, "cover": "封面地址",
"sub_lyric": 翻译歌词内容, "lyric": "歌词内容",
"link": 音乐地址 "sub_lyric": "翻译歌词内容",
"link": "音乐地址",
"served": false
} }
} }
`}</code></pre> `}</code></pre>
+10 -52
View File
@@ -41,7 +41,7 @@ function Wallpaper() {
</code></pre> </code></pre>
<h3>使用方法:</h3> <h3>使用方法:</h3>
<p>调用地址 <code>https://api.paugram.com/wallpaper/</code> 可自动跳转到对应的壁纸(由于运营成本限制,目前本 API 借助 图床/CDN 等平台托管图片。欢迎给予资源赞助~)</p> <p>调用地址 <code>https://api.paugram.com/api/wallpaper</code> 可自动跳转到对应的壁纸(由于运营成本限制,目前本 API 借助 图床/CDN 等平台托管图片。欢迎给予资源赞助~)</p>
<p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p> <p>如果您已开始使用本 API 服务,则默认视为遵守 <a href="https://api.paugram.com/notice">本约定</a>。</p>
<p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p> <p>图片版权归原作者所有,本站不为滥用本 API 进行违规操作者承担责任。</p>
@@ -58,14 +58,9 @@ function Wallpaper() {
<tbody> <tbody>
<tr> <tr>
<td>source</td> <td>source</td>
<td><code>sm</code> <code>cp</code> <code>sina</code> <code>paul</code></td> <td><code>gt</code> <code>gh</code> <code>jsd</code></td>
<td>图片源,如留空则默认采用 sm.ms 源</td> <td>图片源,如留空则默认采用 sm.ms 源</td>
</tr> </tr>
<tr>
<td>category(施工中)</td>
<td><code>us</code> <code>jp</code> <code>cn</code></td>
<td>图片分类,可按不同国家和类别选择</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@@ -81,68 +76,31 @@ function Wallpaper() {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td>sm</td>
<td><em className="green">可用</em></td>
<td>资源较少!sm.ms 图床,国外速度较快,部分浏览器会阻止访问</td>
</tr>
<tr> <tr>
<td>gt</td> <td>gt</td>
<td><em className="green">可用</em></td> <td><em className="green">可用</em></td>
<td>Gitee Pages 服务托管,服务器位于国内,速度稳定</td> <td>Gitee Pages 服务托管,服务器位于国内,速度稳定</td>
</tr> </tr>
<tr>
<td>sina</td>
<td><em className="green">可用</em></td>
<td>资源较少!新浪微博相册,国内速度较快,已更换新地址</td>
</tr>
<tr> <tr>
<td>gh</td> <td>gh</td>
<td><em className="green">可用</em></td> <td><em className="green">可用</em></td>
<td>存放在 GitHub 上的图片资源,基于 JSDelivr 托管,速度非常理想</td> <td>GitHub Pages 服务托管,大多数节点都位于国外(可能会遇到 JP 节点)</td>
</tr>
</tbody>
</table>
</div>
<h3>图片分类(施工中):</h3>
<div className="ks-table text-nowrap">
<table>
<thead>
<tr>
<td>参数名称</td>
<td>状态</td>
<td>分类描述</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><em className="red">不可用</em></td>
<td>白底动漫插图</td>
</tr> </tr>
<tr> <tr>
<td>2</td> <td>jsd</td>
<td><em className="red">不可用</em></td> <td><em className="green">可用</em></td>
<td>透明底动漫插图</td> <td>与存放在 GitHub 上的图片资源同步,基于 JSDelivr 托管,使用 Fastly CDN 宿主</td>
</tr>
<tr>
<td>3</td>
<td><em className="red">不可用</em></td>
<td>随机底动漫壁纸</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<h3>示例:</h3> <h3>示例:</h3>
<p>使用 sm.ms 图片源</p> <p>使用 GitHub 图片源</p>
<pre><code>https://api.paugram.com/wallpaper/?source=sm</code></pre> <pre><code>https://api.paugram.com/api/wallpaper/?source=gh</code></pre>
<p>使用新浪图片源,并选择美漫图片分类</p>
<pre><code>https://api.paugram.com/wallpaper/?source=sina&category=us</code></pre>
<p>在网页背景上使用本 API</p> <p>在网页背景上使用本 API</p>
<pre className="language-css"><code>{`body{ <pre className="language-css"><code>{`body{
background: url("https://api.paugram.com/wallpaper/") center/cover no-repeat; background: url("https://api.paugram.com/api/wallpaper") center/cover no-repeat;
}`} }`}
</code></pre> </code></pre>
<p>在网页背景上使用本 API(伪元素半透明版)</p> <p>在网页背景上使用本 API(伪元素半透明版)</p>
@@ -155,7 +113,7 @@ function Wallpaper() {
z-index: -1; z-index: -1;
content: ""; content: "";
position: fixed; position: fixed;
background: url(https://api.paugram.com/wallpaper/) center/cover; background: url(https://api.paugram.com/api/wallpaper) center/cover;
}`} }`}
</code></pre> </code></pre>