Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
a632079 committed Feb 20, 2018
1 parent 3e28859 commit 4ab75a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Hitokoto-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "Fast & Powerful Hitokoto API Framework.",
"main": "core.js",
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ module.exports = (router, controller) => {
router.get('/nm/url/:id', controller.netease.url)
router.get('/nm/detail/:id', controller.netease.detail)
router.get('/nm/summary/:id', controller.netease.summary)
router.get('/nm/redirect/music/:id', controller.netease.redirectMusic)
router.get('/nm/redirect/picture/:id', controller.netease.redirectPicture)
router.get('/nm/redirect/music/:id', controller.netease.redirect)

return router
}
16 changes: 4 additions & 12 deletions src/controllers/netease.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ controllers.summary = async (ctx, next) => {
data[_.id].artists.push(artist.name)
}
data[_.id].album = {}
data[_.id].album.id = detail.songs[0].al.id
data[_.id].album.name = detail.songs[0].al.name
data[_.id].album.picture = 'https://api.a632079.me/nm/redirect/picture/' + detail.songs[0].al.pic
data[_.id].album.picture = (await nm.picture((await nm.album(detail.songs[0].al.id.toString())).songs[0].al.pic_str)).url

// Get Lyric
if (ctx.query && ctx.query.lyric) {
Expand All @@ -46,21 +47,12 @@ controllers.summary = async (ctx, next) => {
Response400(ctx)
}
}
// Redirect picture URL
controllers.redirectPicture = async (ctx, next) => {
const ret = await nm.picture(ctx.params.id)
if (ret && ret.url) {
ctx.redirect(ret.url)
} else {
Response400(ctx)
}
}

// Redirect Music URL
controllers.redirectMusic = async (ctx, next) => {
controllers.redirect = async (ctx, next) => {
const ret = await nm.url(ctx.params.id)
if (ret && ret.data && ret.data[0].url) {
ctx.redirect(ret.data[0].url.replace('http://', 'https://'))
ctx.redirect(ret.data[0].url.replace(/http:\/\/m(\d+)[a-zA-Z]*/, 'https://m$1'))
} else {
Response400(ctx)
}
Expand Down

0 comments on commit 4ab75a5

Please sign in to comment.