forked from dittos/aniplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
32 lines (30 loc) · 1.06 KB
/
client.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
import {parse as parseUrl} from 'url';
import cheerio from 'cheerio';
async function loadFromUrl(url) {
return cheerio.load(await fetch(url).then(r => r.text()));
}
export async function getVodUpdateList(date) {
const url = `http://m.aniplustv.com/vodUpdateList.asp?curDate=${date}`;
const $ = await loadFromUrl(url);
const itemElements = $('#timeList').find('li').get();
var items = [];
if (itemElements.length > 0 &&
$(itemElements[0]).find('a').attr('href') !== '#') {
items = itemElements.map(item => {
const href = $(item).find('a').attr('href');
const parseQueryString = true;
const parsed = parseUrl(href, parseQueryString);
return {
contentSerial: parsed.query.contentSerial,
part: parsed.query.part,
title: $(item).find('.title').text(),
chapter: $(item).find('.chapter').text(),
pic: $(item).find('.pic img').attr('src'),
};
});
}
return {
date,
items
};
}