@cloud411716/fancy-webnovel 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -161,8 +161,8 @@ function parseRankId(platform, id) {
161
161
  return { channel: 'all', type: id };
162
162
  }
163
163
  case 'qidian': {
164
- // 起点只有主站一个榜单
165
- return { channel: 'main', type: 'main' };
164
+ // id: hotsales / yuepiao / signnewbook / pubnewbook / newauthor
165
+ return { channel: id, type: id };
166
166
  }
167
167
  default:
168
168
  return { channel: 'all', type: 'all' };
@@ -50,15 +50,8 @@ function ensureDir(dir) {
50
50
  // 起点:HTTP mobile SSR(自包含,无需 playwright)
51
51
  // ---------------------------------------------------------------------------
52
52
 
53
- async function scrapeQidian(outDir) {
53
+ async function scrapeQidian(outDir, ranks) {
54
54
  const MOBILE_BASE = 'https://m.qidian.com';
55
- const RANK_TYPES = [
56
- { id: 'hotsales', label: '畅销榜', path: '/rank/hotsales/' },
57
- { id: 'yuepiao', label: '月票榜', path: '/rank/yuepiao/' },
58
- { id: 'signnewbook', label: '签约作者新书榜', path: '/rank/sign/' },
59
- { id: 'pubnewbook', label: '公众作者新书榜', path: '/rank/newbook/' },
60
- { id: 'newauthor', label: '新人作者新书榜', path: '/rank/newauthor/' },
61
- ];
62
55
 
63
56
  const MOBILE_HEADERS = {
64
57
  'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
@@ -69,7 +62,7 @@ async function scrapeQidian(outDir) {
69
62
 
70
63
  const results = [];
71
64
 
72
- for (const rt of RANK_TYPES) {
65
+ for (const rt of ranks) {
73
66
  const url = `${MOBILE_BASE}${rt.path}`;
74
67
  let html = '';
75
68
  try {
@@ -239,8 +232,19 @@ async function main() {
239
232
  let scanFiles = [];
240
233
 
241
234
  if (platform === 'qidian') {
242
- console.error(`→ 采集 起点(mobile SSR)...`);
243
- const results = await scrapeQidian(scanDir);
235
+ const allRanks = [
236
+ { id: 'hotsales', label: '畅销榜', path: '/rank/hotsales/' },
237
+ { id: 'yuepiao', label: '月票榜', path: '/rank/yuepiao/' },
238
+ { id: 'signnewbook', label: '签约作者新书榜', path: '/rank/sign/' },
239
+ { id: 'pubnewbook', label: '公众作者新书榜', path: '/rank/newbook/' },
240
+ { id: 'newauthor', label: '新人作者新书榜', path: '/rank/newauthor/' },
241
+ ];
242
+ const ranks = channel === 'all'
243
+ ? allRanks
244
+ : allRanks.filter(r => r.id === channel);
245
+ if (!ranks.length) { console.error('❌ 未知起点榜单: ' + channel); process.exit(1); }
246
+ console.error(`→ 采集 起点(${channel === 'all' ? '全部' : ranks[0].label})...`);
247
+ const results = await scrapeQidian(scanDir, ranks);
244
248
  if (!results.length) { console.error('❌ 起点采集失败'); process.exit(1); }
245
249
  scanFiles = results.map(r => r.file);
246
250
  } else {
@@ -25,8 +25,14 @@ export function platformLabel(platform) {
25
25
  export function rankOptions(platform) {
26
26
  switch (platform) {
27
27
  case 'qidian':
28
- // 起点男频大热榜(唯一榜单,无细分)
29
- return [{ id: 'main', label: '起点中文网主站榜单' }];
28
+ return [
29
+ { id: 'hotsales', label: '畅销榜' },
30
+ { id: 'yuepiao', label: '月票榜' },
31
+ { id: 'signnewbook', label: '签约作者新书榜' },
32
+ { id: 'pubnewbook', label: '公众作者新书榜' },
33
+ { id: 'newauthor', label: '新人作者新书榜' },
34
+ { id: '__all__', label: '全选' },
35
+ ];
30
36
 
31
37
  case 'fanqie':
32
38
  return [
@@ -83,7 +89,8 @@ export const scan = {
83
89
  return {
84
90
  question: `${platformLabel(platform)} 有多个榜单,支持多选。请选择要采集的榜单:`,
85
91
  hideCustomInput: true,
86
- options: opts.map(o => ({ label: o.label })),
92
+ multiSelect: true,
93
+ options: opts.map(o => ({ id: o.id, label: o.label })),
87
94
  };
88
95
  },
89
96