forked from gaotianliuyun/gao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopymanga_open.js
207 lines (184 loc) · 6.03 KB
/
copymanga_open.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import { Crypto, _, load } from './lib/cat.js';
let key = 'copymanga';
let url = 'https://www.mangacopy.com';
let siteKey = '';
let siteType = 0;
const PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36';
async function request(reqUrl) {
let resp = await req(reqUrl, {
headers: {
'User-Agent': PC_UA,
},
});
return resp.content;
}
// cfg = {skey: siteKey, ext: extend}
async function init(cfg) {
siteKey = cfg.skey;
siteType = cfg.stype;
}
async function home(filter) {
var html = await request(url + '/comics');
const $ = load(html);
let filterObj = {};
let region = {
key: 'region',
name: '地區',
init: '',
};
let regionValues = [];
regionValues.push({ n: '全部', v: '' });
regionValues.push({ n: '日漫', v: '0' });
regionValues.push({ n: '韓漫', v: '1' });
regionValues.push({ n: '美漫', v: '2' });
region['value'] = regionValues;
let ordering = {
key: 'ordering',
name: '排序',
init: '-datetime_updated',
};
let orderingValues = [];
orderingValues.push({ n: '更新時間↓', v: '-datetime_updated' });
orderingValues.push({ n: '更新時間↑', v: 'datetime_updated' });
orderingValues.push({ n: '熱門↓', v: '-popular' });
orderingValues.push({ n: '熱門↑', v: 'popular' });
ordering['value'] = orderingValues;
let status = {
key: 'sort',
name: '狀態',
init: '',
};
let statusValues = [];
statusValues.push({ n: '全部', v: '' });
statusValues.push({ n: '連載中', v: '0' });
statusValues.push({ n: '已完結', v: '1' });
statusValues.push({ n: '短篇', v: '2' });
status['value'] = statusValues;
filterObj['c1'] = [];
let themeValues = [{ n: '全部', v: '' }];
for (const a of $('div.classify-right>a[href*="theme="]')) {
themeValues.push({
n: $(a).text().trim(),
v: a.attribs.href.match(/.*?theme=(.*)&/)[1],
});
}
_.each(_.chunk(themeValues, 11), (vals) => {
let theme = {
key: 'theme',
name: '',
init: '',
value: vals,
};
filterObj['c1'].push(theme);
});
filterObj['c1'].push(region);
filterObj['c1'].push(status);
filterObj['c1'].push(ordering);
return {
class: [{ type_name: 'all', type_id: 'c1' }],
filters: filterObj,
};
}
async function category(tid, pg, filter, extend) {
if (pg == 0) pg = 1;
let link = url + `/comics?theme=${extend.theme || ''}®ion=${extend.region || ''}&status=${extend.status || ''}&ordering=${extend.ordering || '-datetime_updated'}`;
if (pg > 1) {
link += '&offset=' + (pg - 1) * 50 + '&limit=50';
}
var html = await request(link);
const $ = load(html);
const list = eval($('div[class="row exemptComic-box"]')[0].attribs.list);
let books = [];
for (const book of list) {
books.push({
book_id: book.path_word,
book_name: book.name,
book_pic: book.cover,
book_remarks: book.author ? book.author[0].name : '',
});
}
return {
page: pg,
pagecount: list.length == 50 ? pg + 1 : pg,
list: books,
};
}
async function detail(id) {
var html = await request(url + `/comic/${id}`);
const $ = load(html);
let book = {
book_name: $('h6').text().trim(),
book_director: _.map($('span.comicParticulars-right-txt>a[href*="/author/"]'), (a) => $(a).text().trim()).join('/'),
book_content: $('p.intro').text().trim(),
};
const data = JSON.parse(await request(url + `/comicdetail/${id}/chapters`)).results;
var key = Crypto.enc.Utf8.parse('xxxmanga.woo.key');
var iv = Crypto.enc.Utf8.parse(data.substr(0, 16));
var src = Crypto.enc.Hex.parse(data.substr(16));
var dst = Crypto.AES.decrypt({ ciphertext: src }, key, { iv: iv, padding: Crypto.pad.Pkcs7 });
dst = Crypto.enc.Utf8.stringify(dst);
const groups = JSON.parse(dst).groups;
let urls = _.map(groups.default.chapters, (c) => {
return c.name + '$' + id + '|' + c.id;
}).join('#');
book.volumes = '默認';
book.urls = urls;
return {
list: [book],
};
}
async function play(flag, id, flags) {
try {
var info = id.split('|');
var html = await request(url + `/comic/${info[0]}/chapter/${info[1]}`);
const $ = load(html);
const data = $('div.imageData')[0].attribs.contentkey;
var key = Crypto.enc.Utf8.parse('xxxmanga.woo.key');
var iv = Crypto.enc.Utf8.parse(data.substr(0, 16));
var src = Crypto.enc.Hex.parse(data.substr(16));
var dst = Crypto.AES.decrypt({ ciphertext: src }, key, { iv: iv, padding: Crypto.pad.Pkcs7 });
dst = Crypto.enc.Utf8.stringify(dst);
const list = JSON.parse(dst);
var content = [];
for (let index = 0; index < list.length; index++) {
const element = list[index];
content[index] = element.url;
}
return {
content: content,
};
} catch (e) {
return {
content: '',
};
}
}
async function search(wd, quick, pg) {
if (pg == 0) pg = 1;
const link = `${url}/api/kb/web/searcha/comics?offset=${pg > 1 ? ((pg - 1) * 12).toString() : ''}&platform=2&limit=12&q=${wd}&q_type=`;
var list = JSON.parse(await request(link)).results.list;
const books = [];
for (const book of list) {
books.push({
book_id: book.path_word,
book_name: book.name,
book_pic: book.cover,
book_remarks: book.author ? book.author[0].name : '',
});
}
return {
page: pg,
pagecount: list.length == 12 ? pg + 1 : pg,
list: books,
};
}
export function __jsEvalReturn() {
return {
init: init,
home: home,
category: category,
detail: detail,
play: play,
search: search,
};
}