feat(route): add LiSA (#10755)
* feat(route): add LiSA * Add a linebreak before next heading Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix title Co-authored-by: Tony <TonyRL@users.noreply.github.com> * use art-template * fix docs link * rename folder * fix router url according to new folder name * fix router path & example path in doc * append radar detectable source * Update lib/v2/lxixsxa/templates/disco.art Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/lxixsxa/templates/info.art Co-authored-by: Weijian Li <ri1ken@r1ks-mba.local>
This commit is contained in:
parent
ed502478b3
commit
69cd00d1a4
|
|
@ -4,6 +4,16 @@ pageClass: routes
|
|||
|
||||
# Live
|
||||
|
||||
## LiSA
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="Kiotlin" example="/lxixsxa/info" path="/lxixsxa/info" radar="1" rssbud="1" />
|
||||
|
||||
### Latest Discography
|
||||
|
||||
<RouteEn author="Kiotlin" example="/lxixsxa/disco" path="/lxixsxa/disco" radar="1" rssbud="1" />
|
||||
|
||||
## V LIVE
|
||||
|
||||
### Board
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseJSONP } = require('./jsonpHelper');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const api = 'https://www.sonymusic.co.jp/json/v2/artist/lisa/discography/start/0/count/-1';
|
||||
const url = 'https://www.sonymusic.co.jp/artist/lisa/discography';
|
||||
|
||||
const title = 'LATEST DISCOGRAPHY';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: api,
|
||||
});
|
||||
|
||||
const data = parseJSONP(response.data).items.map((item) => ({
|
||||
title: item.title,
|
||||
referID: item.representative_goods_number,
|
||||
imageLink: item.image !== '' ? item.image : item.image_original,
|
||||
type: item.type,
|
||||
releaseDate: item.release_date,
|
||||
price: item.price !== '' ? item.price + ' (Tax Inclusive)' : 'Unknown Yet',
|
||||
description: item.comment,
|
||||
comment: item.catch_copy !== '' ? item.catch_copy : '今日もいい日だ!',
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
// the source title
|
||||
title,
|
||||
// the source url
|
||||
link: url,
|
||||
// the source description
|
||||
description: "LiSA's Latest Albums",
|
||||
// iterate through all leaf objects
|
||||
item: data.map((item) => ({
|
||||
// the article title
|
||||
title: item.title,
|
||||
// the article content
|
||||
description: art(path.join(__dirname, 'templates/disco.art'), {
|
||||
comment: item.comment,
|
||||
type: item.type,
|
||||
price: item.price,
|
||||
image: item.imageLink,
|
||||
description: item.description,
|
||||
}),
|
||||
// the article publish time
|
||||
pubDate: parseDate(item.releaseDate),
|
||||
// the article link
|
||||
link: `${url}/${item.referID}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseJSONP } = require('./jsonpHelper');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const api = 'https://www.sonymusic.co.jp/json/v2/artist/lisa/information/start/0/count/-1';
|
||||
const url = 'https://www.sonymusic.co.jp/artist/lisa/info';
|
||||
|
||||
const title = 'NEWS';
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: api,
|
||||
});
|
||||
|
||||
const data = parseJSONP(response.data).items.map((item) => ({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
category: item.category,
|
||||
date: item.date,
|
||||
description: item.article,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
// the source title
|
||||
title,
|
||||
// the source url
|
||||
link: url,
|
||||
// the source description
|
||||
description: "Let's see what is new about LiSA.",
|
||||
// iterate through all leaf objects
|
||||
item: data.map((item) => ({
|
||||
// the article title
|
||||
title: item.title,
|
||||
// the article content
|
||||
description: art(path.join(__dirname, 'templates/info.art'), {
|
||||
category: item.category,
|
||||
description: item.description.replace(/\n/g, '<br>'),
|
||||
}),
|
||||
// the article publish time
|
||||
pubDate: parseDate(item.date),
|
||||
// the article link
|
||||
link: `${url}/${item.id}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
function parseJSONP(jsonpData) {
|
||||
try {
|
||||
const startPos = jsonpData.indexOf('({');
|
||||
const endPos = jsonpData.lastIndexOf('})');
|
||||
let jsonString = jsonpData.substring(startPos + 1, endPos + 1);
|
||||
|
||||
// remove escaped single quotes since they are not valid json
|
||||
jsonString = jsonString.replace(/\\'/g, "'");
|
||||
|
||||
return JSON.parse(jsonString);
|
||||
} catch (e) {
|
||||
const error = new Error(`Failed to convert jsonp to json. ${e.message}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parseJSONP,
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/info': ['Kiotlin'],
|
||||
'/disco': ['Kiotlin'],
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
module.exports = {
|
||||
'sonymusic.co.jp': {
|
||||
_name: 'Sony Music',
|
||||
www: [
|
||||
{
|
||||
title: 'LiSA News',
|
||||
docs: 'https://docs.rsshub.app/en/live.html#lisa',
|
||||
source: ['/artist/lisa/', '/artist/lisa/info/'],
|
||||
target: '/lxixsxa/info',
|
||||
},
|
||||
{
|
||||
title: 'LiSA Albums',
|
||||
docs: 'https://docs.rsshub.app/en/live.html#lisa',
|
||||
source: ['/artist/lisa/', '/artist/lisa/discography/'],
|
||||
target: '/lxixsxa/disco',
|
||||
},
|
||||
],
|
||||
},
|
||||
'lxixsxa.com': {
|
||||
_name: 'LiSA Official',
|
||||
www: [
|
||||
{
|
||||
title: 'News',
|
||||
docs: 'https://docs.rsshub.app/en/live.html#lisa',
|
||||
source: ['/', '/info'],
|
||||
target: '/lxixsxa/info',
|
||||
},
|
||||
{
|
||||
title: 'Albums',
|
||||
docs: 'https://docs.rsshub.app/en/live.html#lisa',
|
||||
source: ['/', '/discography'],
|
||||
target: '/lxixsxa/disco',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/info', require('./information'));
|
||||
router.get('/disco', require('./discography'));
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<span>{{comment}} Type: {{type}} Price: {{price}}</span>
|
||||
{{ if image }}
|
||||
<img src={{image}} />
|
||||
{{ /if }}
|
||||
{{@ description }}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{{ if category }}
|
||||
<span>Category: {{category}}</span>
|
||||
{{ /if }}
|
||||
{{@ description }}
|
||||
Loading…
Reference in New Issue