Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
Update apis
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Jan 17, 2019
1 parent f03be82 commit 95e4fff
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 604 deletions.
2 changes: 1 addition & 1 deletion NeteaseCloudMusicApi
255 changes: 34 additions & 221 deletions server/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

/* eslint-disable */
import fs from 'fs';
import path from 'path';
import express from 'express';
import cookieParser from 'cookie-parser';
import apicache from 'apicache'
Expand All @@ -10,6 +12,12 @@ const app = express();
const cache = apicache.middleware;
const onlyStatus200 = (req, res) => res.statusCode === 200;
const port = process.env.API_PORT || 8000;
const special = {
'daily_signin.js': '/daily_signin',
'fm_trash.js': '/fm_trash',
'personal_fm.js': '/personal_fm'
};
const apisDir = '../NeteaseCloudMusicApi/module';

app.use(cookieParser());

Expand All @@ -21,227 +29,32 @@ app.use((req, res, next) => {
next();
});

// 获取专辑内容
app.use('/album', require('../NeteaseCloudMusicApi/router/album'));

// 获取歌手单曲
app.use('/artists', require('../NeteaseCloudMusicApi/router/artists'));

// 获取歌手专辑列表
app.use('/artist/album', require('../NeteaseCloudMusicApi/router/artist_album'));

// 艺术家-信息
app.use('/artist/desc', require('../NeteaseCloudMusicApi/router/artists_desc'));

// 艺术家-mv
app.use('/artist/mv', require('../NeteaseCloudMusicApi/router/artists_mv'));

// 获取 banner
app.use('/banner', require('../NeteaseCloudMusicApi/router/banner'));

app.use('/check/music', require('../NeteaseCloudMusicApi/router/check_music'));

app.use('/comment/music', require('../NeteaseCloudMusicApi/router/comment_music'));

app.use('/comment/mv', require('../NeteaseCloudMusicApi/router/comment_mv'));

app.use('/comment/album', require('../NeteaseCloudMusicApi/router/comment_album'));

app.use('/comment/playlist', require('../NeteaseCloudMusicApi/router/comment_playlist'));

app.use('/comment/dj', require('../NeteaseCloudMusicApi/router/comment_dj'));

// 签到
app.use('/daily_signin', require('../NeteaseCloudMusicApi/router/daily_signin'));

// djradio detail
app.use('/dj/detail', require('../NeteaseCloudMusicApi/router/dj_detail'));

// dj主播 radio
app.use('/dj/program', require('../NeteaseCloudMusicApi/router/dj_program'));

app.use('/dj/program/detail', require('../NeteaseCloudMusicApi/router/dj_program_detail'));

app.use('/dj/sub', require('../NeteaseCloudMusicApi/router/dj_sub'));

app.use('/dj/catelist', require('../NeteaseCloudMusicApi/router/dj_catelist'));

app.use('/dj/hot', require('../NeteaseCloudMusicApi/router/dj_hot'));

// 精选电台
app.use('/dj/recommend', require('../NeteaseCloudMusicApi/router/dj_recommend'));

// 精选电台-分类电台
app.use('/dj/recommend/type', require('../NeteaseCloudMusicApi/router/dj_recommend_type'));

// 获取动态
app.use('/event', require('../NeteaseCloudMusicApi/router/event'));

// 垃圾桶
app.use('/fm_trash', require('../NeteaseCloudMusicApi/router/fm_trash'));

// 喜欢歌曲
app.use('/like', require('../NeteaseCloudMusicApi/router/like'));

app.use('/likelist', require('../NeteaseCloudMusicApi/router/likelist'));

// 不明 api
app.use('/log/web', require('../NeteaseCloudMusicApi/router/logWeb'));

// 获取歌词
app.use('/lyric', require('../NeteaseCloudMusicApi/router/lyric'));

// 获取音乐 url
app.use('/music/url', require('../NeteaseCloudMusicApi/router/musicUrl'));

// 最新 mv
app.use('/mv/first', require('../NeteaseCloudMusicApi/router/mv_first'));

// 播放 mv
app.use('/mv/url', require('../NeteaseCloudMusicApi/router/mv_url'));

// mv
app.use('/mv', require('../NeteaseCloudMusicApi/router/mv'));

// 私人 FM
app.use('/personal_fm', require('../NeteaseCloudMusicApi/router/personal_fm'));

// 推荐歌单
app.use('/personalized', cache('120 minutes', onlyStatus200), require('../NeteaseCloudMusicApi/router/personalized'));

// 推荐dj
app.use('/personalized/djprogram', require('../NeteaseCloudMusicApi/router/personalized_djprogram'));

// 推荐新音乐
app.use('/personalized/newsong', require('../NeteaseCloudMusicApi/router/personalized_newsong'));

// 独家放送
app.use(
'/personalized/privatecontent',
require('../NeteaseCloudMusicApi/router/personalized_privatecontent')
);

// 推荐mv
app.use('/personalized/mv', require('../NeteaseCloudMusicApi/router/personalized_mv'));

// 获取歌单内列表
app.use('/playlist/detail', require('../NeteaseCloudMusicApi/router/playlist_detail'));

// 收藏单曲到歌单,从歌单删除歌曲 op=del,add;pid=歌单id,tracks=歌曲id
app.use('/playlist/tracks', require('../NeteaseCloudMusicApi/router/playlist_tracks'));

app.use('/playlist/hot', require('../NeteaseCloudMusicApi/router/playlist_hot'));

app.use('/playlist/catlist', require('../NeteaseCloudMusicApi/router/playlist_catlist'));

// 推荐节目
app.use('/program/recommend', require('../NeteaseCloudMusicApi/router/program_recommend'));

// 获取每日推荐歌曲
app.use('/recommend/songs', cache('120 minutes', onlyStatus200), require('../NeteaseCloudMusicApi/router/recommend_songs'));

// 获取每日推荐歌单
app.use('/recommend/resource', cache('120 minutes', onlyStatus200), require('../NeteaseCloudMusicApi/router/recommend_resource'));

// 取消推荐
app.use('/recommend/dislike', require('../NeteaseCloudMusicApi/router/recommend_dislike'));

app.use('/resource/like', require('../NeteaseCloudMusicApi/router/resource_like'));

// 搜索
app.use('/search', require('../NeteaseCloudMusicApi/router/search'));

// 搜索 multimatch
app.use('/search/multimatch', require('../NeteaseCloudMusicApi/router/search_multimatch'));

// 搜索 suggest,搜索结果包含单曲,歌手,歌单,mv信息
app.use('/search/suggest', require('../NeteaseCloudMusicApi/router/search_suggest'));

// simi ,相似歌单
app.use('/simi/playlist', require('../NeteaseCloudMusicApi/router/simi_playlist'));

// simi ,相似歌曲
app.use('/simi/song', require('../NeteaseCloudMusicApi/router/simi_song'));

// 相似 mv
app.use('/simi/mv', require('../NeteaseCloudMusicApi/router/simi_mv'));

// simi ,相似关注的用户
app.use('/simi/user', require('../NeteaseCloudMusicApi/router/simi_user'));

// 相似歌手
app.use('/simi/artist', require('../NeteaseCloudMusicApi/router/simi_artists'));

// 获取音乐详情
app.use('/song/detail', require('../NeteaseCloudMusicApi/router/song_detail'));

// 新碟上架 http://music.163.com/#/discover/album/
app.use('/top/album', require('../NeteaseCloudMusicApi/router/top_album'));

// 热门歌手 http://music.163.com/#/discover/artist/
app.use('/top/artists', require('../NeteaseCloudMusicApi/router/top_artists'));

app.use('/top/list', require('../NeteaseCloudMusicApi/router/top_list'));

app.use('/top/mv', require('../NeteaseCloudMusicApi/router/top_mv'));

// 分类歌单
app.use('/top/playlist', require('../NeteaseCloudMusicApi/router/top_playlist'));

// 精品歌单
app.use(
'/top/playlist/highquality',
require('../NeteaseCloudMusicApi/router/top_playlist_highquality')
);

app.use('/top/song', require('../NeteaseCloudMusicApi/router/top_songs'));

app.use('/toplist', require('../NeteaseCloudMusicApi/router/toplist'));

app.use('/toplist/artist', require('../NeteaseCloudMusicApi/router/toplist_artist'));

app.use('/toplist/detail', require('../NeteaseCloudMusicApi/router/toplist_detail'));

// 获取用户歌单
app.use('/user/playlist', require('../NeteaseCloudMusicApi/router/user_playlist'));

// 获取用户电台
app.use('/user/audio', require('../NeteaseCloudMusicApi/router/user_audio'));

// 云盘数据
app.use('/user/cloud', require('../NeteaseCloudMusicApi/router/user_cloud'));

// 云盘数据详情? 暂时不要使用
app.use('/user/cloud/search', require('../NeteaseCloudMusicApi/router/user_cloud_search'));

// 用户动态
app.use('/user/event', require('../NeteaseCloudMusicApi/router/user_event'));

app.use('/user/detail', require('../NeteaseCloudMusicApi/router/user_detail'));

app.use('/user/dj', require('../NeteaseCloudMusicApi/router/user_dj'));

app.use('/user/followeds', require('../NeteaseCloudMusicApi/router/user_followeds'));

app.use('/user/follows', require('../NeteaseCloudMusicApi/router/user_follows'));

app.use('/user/subcount', require('../NeteaseCloudMusicApi/router/user_subcount'));

app.use('/user/record', require('../NeteaseCloudMusicApi/router/user_playrecord'));

// New added
app.use('/thumbsup', require('./api/thumbsup'));
app.use('/hot/album', require('./api/hot_album'));
app.use('/subscribe', require('./api/subscribe'));
app.use('/unsubscribe', require('./api/unsubscribe'));
app.use('/follow', require('./api/follow'));
app.use('/unfollow', require('./api/unfollow'));
app.use('/sub', require('./api/sub'));
app.use('/unsub', require('./api/unsub'));
app.use('/login/cellphone', require('./api/loginCellphone'));
app.use('/login/refresh', cache('1 hour', onlyStatus200), require('./api/login_refresh'));
app.use('/login', require('./api/login'));
app.use('/scrobble', require('./api/scrobble'));
fs.readdirSync(path.join(__dirname, apisDir)).reverse().forEach(file => {
if (!/\.js$/i.test(file)) {
return;
}
let route = (file in special) ? special[file] : '/' + file.replace(/\.js$/i, '').replace(/_/g, '/');
let question = require(path.join(__dirname, apisDir, file));
let request = require(`../NeteaseCloudMusicApi/util/request`);

app.use(route, (req, res) => {
let query = Object.assign({}, req.query, req.body, { cookie: req.cookies });
question(query, request)
.then(answer => {
console.log('[OK]', decodeURIComponent(req.originalUrl));
res.append('Set-Cookie', answer.cookie);
res.status(answer.status).send(answer.body);
})
.catch(answer => {
console.log('[ERR]', decodeURIComponent(req.originalUrl));
if (answer.body.code === 301) {
answer.status = 200;
}
res.append('Set-Cookie', answer.cookie);
res.status(answer.status).send(answer.body);
});
});
});

app.use('/api/home', require('./router/home'));
app.use('/api/player', require('./router/player'));
Expand Down
27 changes: 0 additions & 27 deletions server/api/follow.js

This file was deleted.

24 changes: 0 additions & 24 deletions server/api/hot_album.js

This file was deleted.

39 changes: 0 additions & 39 deletions server/api/login.js

This file was deleted.

Loading

0 comments on commit 95e4fff

Please sign in to comment.