1 Star 5 Fork 15

Honrun/CatVodOpenJson

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MyCatBookan.js 3.64 KB
一键复制 编辑 原始数据 按行查看 历史
hehongyun 提交于 2024-02-20 10:38 . first update
import { _ } from './lib/cat.js';
let key = 'bookan';
let url = 'https://api.bookan.com.cn';
let siteKey = '';
let siteType = 0;
async function request(reqUrl, agentSp) {
let res = await req(reqUrl, {
method: 'get',
});
return res.content;
}
// cfg = {skey: siteKey, ext: extend}
async function init(cfg) {
siteKey = cfg.skey;
siteType = cfg.stype;
}
async function home(filter) {
return JSON.stringify({
class: [
{ type_id: '1305', type_name: '少年读物' },
{ type_id: '1304', type_name: '儿童文学' },
{ type_id: '1320', type_name: '国学经典' },
{ type_id: '1306', type_name: '文艺少年' },
{ type_id: '1309', type_name: '育儿心经' },
{ type_id: '1310', type_name: '心理哲学' },
{ type_id: '1307', type_name: '青春励志' },
{ type_id: '1312', type_name: '历史小说' },
{ type_id: '1303', type_name: '故事会' },
{ type_id: '1317', type_name: '音乐戏剧' },
{ type_id: '1319', type_name: '相声评书' },
],
});
}
async function homeVod() {
return JSON.stringify({
list: [],
});
}
async function category(tid, pg, filter, extend) {
pg = pg || 1;
if (pg == 0) pg = 1;
let content = await request(`${url}/voice/book/list?instance_id=25304&page=${pg}&category_id=${tid}&num=24`);
let data = JSON.parse(content).data;
let books = [];
for (const book of data.list) {
books.push({
vod_id: book.id,
vod_name: book.name,
vod_pic: book.cover,
vod_remarks: book.extra.author,
});
}
return JSON.stringify({
page: data.current_page,
pagecount: data.last_page,
limit: 24,
total: data.total,
list: books,
});
}
async function detail(id) {
let content = await request(`${url}/voice/album/units?album_id=${id}&page=1&num=200&order=1`);
let data = JSON.parse(content).data;
console.log(JSON.stringify(data));
let book = {
vod_id: id,
type_name: '',
vod_year: '',
vod_area: '',
vod_remarks: '',
vod_actor: '',
vod_director: '',
vod_content: '',
};
let us = _.map(data.list, function (b) {
return formatPlayUrl(b.title) + '$' + b.file;
}).join('#');
book.vod_play_from = '书卷';
book.vod_play_url = us;
return JSON.stringify({
list: [book],
});
}
function formatPlayUrl(name) {
return name
.trim()
.replace(/<|>|\.《.*?》/g, '. ')
.replace(/\$|#/g, ' ')
.trim();
}
async function proxy(segments, headers) {}
async function play(flag, id, flags) {
return JSON.stringify({
parse: 0,
url: id,
});
}
async function search(wd, quick, pg) {
pg = pg || 1;
if (pg == 0) pg = 1;
let content = await request(`https://es.bookan.com.cn/api/v3/voice/book?instanceId=25304&keyword=${wd}&pageNum=${pg}&limitNum=20`);
let data = JSON.parse(content).data;
let books = [];
for (const book of data.list) {
books.push({
vod_id: book.id,
vod_name: book.name,
vod_pic: book.cover,
vod_remarks: book.extra.author,
});
}
return JSON.stringify({
page: data.current_page,
pagecount: data.last_page,
limit: 20,
total: data.total,
list: books,
});
}
export function __jsEvalReturn() {
return {
init: init,
home: home,
homeVod: homeVod,
category: category,
detail: detail,
play: play,
search: search,
};
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/honrun_he/CatVodOpenJson.git
git@gitee.com:honrun_he/CatVodOpenJson.git
honrun_he
CatVodOpenJson
CatVodOpenJson
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385