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

View File

@ -31,6 +31,7 @@ export default Api(
}
}
// 直接播放
if ("play" in ctx.query) {
ctx.status = 302;
ctx.set("location", `https://music.163.com/song/media/outer/url?id=${id}`);

View File

@ -6,7 +6,7 @@ import { client } from './utils/redis';
export default Api(
Get(),
Query<{ id?: string }>(),
Query<{ id?: string, play?: string }>(),
async () => {
const ctx = useContext();
@ -15,6 +15,21 @@ export default Api(
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);
@ -27,11 +42,12 @@ export default Api(
title: cached[0],
artist: cached[1],
album: cached[2],
cover: cached[3],
lyric: cached[4],
sub_lyric: cached[5],
link: cached[6],
served: Boolean(cached[7]),
alias: cached[3],
cover: cached[4],
lyric: cached[5],
sub_lyric: cached[6],
link: cached[7],
served: Boolean(cached[8]),
cached: true
}
};
@ -45,6 +61,7 @@ export default Api(
song.title,
song.artist,
song.album,
song.alias,
song.cover,
song.lyric,
song.sub_lyric,

View File

@ -46,6 +46,7 @@ export const parseSongData = async (item: any) => {
id: item.id,
title: item.name,
artist: item.artists ?. [0].name || "",
alias: item.alias ?. [0] || "",
album: item.album.name || "",
cover: `${item.album.picUrl.replace("http://", "https://")}?param=250y250"`,
lyric,

View File

@ -54,7 +54,7 @@ function ACGM() {
<ArticleHead title="随机动漫音乐" desc="输出一首随机的动漫音乐及信息,基于网易云 API" />
<article className="post">
<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 </p>
<p>使 <code>Cookie</code> </p>
@ -71,7 +71,7 @@ function ACGM() {
</thead>
<tbody>
<tr>
<td>list</td>
<td>list</td>
<td> <code></code> <code></code></td>
<td></td>
</tr>
@ -116,32 +116,59 @@ function ACGM() {
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td> ID</td>
<td><code>string</code></td>
</tr>
<tr>
<td>title</td>
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>artist</td>
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>album</td>
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>alias</td>
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>cover</td>
<td>https</td>
<td>https</td>
<td><code>string</code></td>
</tr>
<tr>
<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>
</tbody>
</table>
@ -149,23 +176,31 @@ function ACGM() {
<h3></h3>
<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,
"title": "初登校",
"artist": "橋本由香利",
"album": "ひなこのーと COMPLETE SOUNDTRACK",
"cover": ,
"link":
"code": 1,
"msg": "Success",
"data": {
"id": 435289265,
"title": "問題がある人たち",
"artist": "吟",
"alias": "",
"album": "この美術部には問題がある! オリジナルサウンドトラックCD vol.1",
"cover": "封面地址",
"lyric": "歌词内容",
"sub_lyric": "翻译歌词内容",
"link": "音乐地址",
"served": false
}
}
`}</code></pre>
<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>
<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>
<p></p>

View File

@ -18,7 +18,7 @@ function Bing() {
<ArticleHead title="必应每日壁纸" desc="每日更新,尽享乐趣" />
<article className="post">
<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 </p>
@ -42,9 +42,9 @@ function Bing() {
<h3></h3>
<p></p>
<pre><code>https://api.paugram.com/bing</code></pre>
<pre><code>https://api.paugram.com/api/bing</code></pre>
<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>
<p>使 API</p>
<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>
<p>使 API</p>
@ -67,7 +67,7 @@ function Bing() {
z-index: -1;
content: "";
position: fixed;
background: url(https://api.paugram.com/bing/) center/cover;
background: url(https://api.paugram.com/api/bing) center/cover;
}`}
</code></pre>

View File

@ -18,12 +18,11 @@ function Netease() {
<ArticleHead title="网易云解析" desc="解析音乐并精简输出,配合 Kico Player 使用更佳" />
<article className="post">
<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 </p>
<h3></h3>
<p>使 <code>id</code> </p>
<div className="ks-table text-nowrap">
<table>
<thead>
@ -39,11 +38,6 @@ function Netease() {
<td> ID<code>517567145</code></td>
<td> ID</td>
</tr>
<tr>
<td>playlist</td>
<td></td>
<td></td>
</tr>
<tr>
<td>play</td>
<td> <code>true</code> </td>
@ -84,6 +78,11 @@ function Netease() {
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>alias</td>
<td></td>
<td><code>string</code></td>
</tr>
<tr>
<td>cover</td>
<td>https</td>
@ -115,7 +114,7 @@ function Netease() {
<h3></h3>
<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,
"msg": "Success",
"data": {
"id": 517567145,
"title": "初登校",
"artist": "橋本由香利",
"album": "ひなこのーと COMPLETE SOUNDTRACK",
"cover": ,
"lyric": ,
"sub_lyric": ,
"link":
"id": 448143347,
"title": "STARTING NOW!",
"artist": "水樹奈々",
"album": "NEOGENE CREATION",
"alias": "TV动画《这个美术社大有问题!》片头曲",
"cover": "封面地址",
"lyric": "歌词内容",
"sub_lyric": "翻译歌词内容",
"link": "音乐地址",
"served": false
}
}
`}</code></pre>

View File

@ -41,7 +41,7 @@ function Wallpaper() {
</code></pre>
<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 </p>
@ -58,14 +58,9 @@ function Wallpaper() {
<tbody>
<tr>
<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>
</tr>
<tr>
<td>category</td>
<td><code>us</code> <code>jp</code> <code>cn</code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
@ -81,68 +76,31 @@ function Wallpaper() {
</tr>
</thead>
<tbody>
<tr>
<td>sm</td>
<td><em className="green"></em></td>
<td>sm.ms 访</td>
</tr>
<tr>
<td>gt</td>
<td><em className="green"></em></td>
<td>Gitee Pages </td>
</tr>
<tr>
<td>sina</td>
<td><em className="green"></em></td>
<td></td>
</tr>
<tr>
<td>gh</td>
<td><em className="green"></em></td>
<td> GitHub JSDelivr </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>
<td>GitHub Pages JP </td>
</tr>
<tr>
<td>2</td>
<td><em className="red"></em></td>
<td></td>
</tr>
<tr>
<td>3</td>
<td><em className="red"></em></td>
<td></td>
<td>jsd</td>
<td><em className="green"></em></td>
<td> GitHub JSDelivr 使 Fastly CDN 宿</td>
</tr>
</tbody>
</table>
</div>
<h3></h3>
<p>使 sm.ms </p>
<pre><code>https://api.paugram.com/wallpaper/?source=sm</code></pre>
<p>使</p>
<pre><code>https://api.paugram.com/wallpaper/?source=sina&category=us</code></pre>
<p>使 GitHub </p>
<pre><code>https://api.paugram.com/api/wallpaper/?source=gh</code></pre>
<p>使 API</p>
<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>
<p>使 API</p>
@ -155,7 +113,7 @@ function Wallpaper() {
z-index: -1;
content: "";
position: fixed;
background: url(https://api.paugram.com/wallpaper/) center/cover;
background: url(https://api.paugram.com/api/wallpaper) center/cover;
}`}
</code></pre>