This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
112 lines (91 loc) · 3.7 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
global.L = (console || 1).log;
let _fs = require('fs');
let Axios = require('axios');
let U = require('./util');
let Maker = {
bioA: async function(name) {
let result = [];
let cnc = (await Axios.get(`https://yz.lol.qq.com/v1/zh_cn/champions/${name}/index.json`)).data.champion;
let enc = (await Axios.get(`https://universe-meeps.leagueoflegends.com/v1/en_us/champions/${name}/index.json`)).data.champion;
result.push(`# <${cnc.title}> ${cnc.name}\r\n### <${U.firstUpCase(enc.title)}> ${U.firstUpCase(enc.name)}`);
result.push('');
let full = U.makePara(
cnc.biography.full.trim().split(/<\/p>/),
enc.biography.full.trim().split(/<\/p>/),
true
);
let quote = U.makeQuote(
cnc.biography.quote.trim(), cnc.biography['quote-author'] || cnc.name,
enc.biography.quote.trim(), enc.biography['quote-author'] || enc.name,
);
let short = U.makeShort(
cnc.biography.short.trim(),
enc.biography.short.trim()
);
return U.makeHead()
.concat(result)
.concat(quote)
.concat(short)
.concat(full)
.concat(U.makeTran())
.concat(U.makeTail(0));
},
stoA: async function(title) {
let header = [];
let cns = (await Axios.get(`https://yz.lol.qq.com/v1/zh_cn/story/${title}/index.json`)).data.story;
let ens = (await Axios.get(`https://universe-meeps.leagueoflegends.com/v1/en_us/story/${title}/index.json`)).data.story;
header.push(`# ${cns.title} ${U.firstUpCase(ens.title)}`);
header.push(`> 作者 Author: ${ens.subtitle.replace(/^by ?/, '')}`);
header.push('>');
header.push(`> 相关英雄 Related Champion: ${cns['story-sections'][0]['featured-champions'][0].name} (${ens['story-sections'][0]['featured-champions'][0].name})`);
header.push('>');
let counter = { start: 0 };
let full = [];
for(let i=0; i<cns['story-sections'][0]['story-subsections'].length;i++) {
full = full.concat(U.makeHara(
cns['story-sections'][0]['story-subsections'][i].content.trim().split(/<p><p><hr.*?story-divider.*?p><\/p>/g),
ens['story-sections'][0]['story-subsections'][i].content.trim().split(/<p><p><hr.*?story-divider.*?p><\/p>/g),
true,
false,
counter
));
}
return U.makeHead()
.concat(header)
.concat(U.makeCata(counter.start))
.concat(full)
.concat(U.makeTran())
.concat(U.makeTail(1));
},
stoB: async function(title) {
let header = [];
let cns = (await Axios.get(`https://yz.lol.qq.com/v1/zh_cn/story/${title}/index.json`)).data.story;
let ens = (await Axios.get(`https://universe-meeps.leagueoflegends.com/v1/en_us/story/${title}/index.json`)).data.story;
header.push(`# ${cns.title} ${U.firstUpCase(ens.title)}`);
header.push(`> 作者 Author: ${ens.subtitle.replace(/^by ?/, '')}`);
header.push('>');
header.push(`> 相关英雄 Related Champion: ${cns['story-sections'][0]['featured-champions'][0].name} (${ens['story-sections'][0]['featured-champions'][0].name})`);
header.push('>');
let counter = { start: 0 };
let full = [];
for(let i=0; i<cns['story-sections'][0]['story-subsections'].length;i++) {
full = full.concat(U.makePara(
cns['story-sections'][0]['story-subsections'][i].content.trim().split(/<\/p>/),
ens['story-sections'][0]['story-subsections'][i].content.trim().split(/<\/p>/),
true,
false,
counter
));
}
return U.makeHead()
.concat(header)
.concat(U.makeCata(counter.start))
.concat(full)
.concat(U.makeTran())
.concat(U.makeTail(1));
}
};
(async function main() {
// _fs.writeFileSync('./Biography.md', (await Maker.bioA('kaisa')).join('\r\n'));
_fs.writeFileSync('./Shtory.md', (await Maker.stoB('aurelionsol-color-story')).join('\r\n'));
})();