加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
douyu_open.js 3.51 KB
一键复制 编辑 原始数据 按行查看 历史
hehongyun 提交于 2024-02-20 10:38 . first update
import { Crypto, load, _ } from 'assets://js/lib/cat.js';
let key = 'douyu';
let host = 'http://live.yj1211.work';
let siteKey = '';
let siteType = 0;
const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36';
async function requestRaw(reqUrl, redirect) {
let resRaw = await req(reqUrl, {
method: 'get',
headers: {
'User-Agent': MOBILE_UA,
},
redirect: redirect,
});
return resRaw;
}
async function request(reqUrl) {
let resRaw = await requestRaw(reqUrl, 1)
return resRaw.content;
}
// cfg = {skey: siteKey, ext: extend}
async function init(cfg) {
}
async function home(filter) {
const classes = [
{ type_id: "热门游戏", type_name: "热门游戏" },
{ type_id: "主机游戏", type_name: "主机游戏" },
{ type_id: "原创IP", type_name: "原创IP" },
];
const filterObj = {};
return JSON.stringify({
class: _.map(classes, (cls) => {
cls.land = 1;
cls.ratio = 1.78;
return cls;
}),
filters: filterObj,
});
}
async function homeVod() {
const data = JSON.parse(await request(host + '/api/live/getRecommendByPlatformArea?platform=douyu&size=20&area=热门游戏&page=1'));
let videos = _.map(data.data.list, (it) => {
return {
vod_id: it.roomId,
vod_name: it.roomName,
vod_pic: it.roomPic,
vod_remarks: it.ownerName,
}
});
return JSON.stringify({
list: videos,
});
}
async function category(tid, pg, filter, extend) {
if (pg <= 0 || typeof pg == 'undefined') pg = 1;
const data = JSON.parse(await request(host + '/api/live/getRecommendByPlatformArea?platform=douyu&size=20&area=' + tid + '&page=' + pg));
let videos = _.map(data.data, (it) => {
return {
vod_id: it.roomId,
vod_name: it.roomName,
vod_pic: it.roomPic,
vod_remarks: it.ownerName,
}
});
return JSON.stringify({
page: parseInt(pg),
pagecount: 9999,
limit: 90,
total: 999999,
list: videos,
});
}
async function detail(id) {
const data = JSON.parse(await request(host + '/api/live/getRoomInfo?platform=douyu&roomId=' + id));
const video = data.data;
let vod = {
vod_id: video.roomId,
vod_name: video.roomName,
vod_pic: video.roomPic,
vod_remarks: video.categoryName,
type_name: video.categoryName,
vod_director: video.ownerName,
vod_actor: '在线人数:' + video.online,
vod_content: "",
vod_year: "",
vod_area: "",
};
vod.vod_play_from = video.platForm;
vod.vod_play_url = '原画$' + id;
return JSON.stringify({
list: [vod],
});
}
async function play(flag, id, flags) {
const resp = await requestRaw('https://getplayurl.lmteam.repl.co/live?platform=douyu&rid=' + id, 0);
const headers = resp.headers;
let url = "";
if (headers.hasOwnProperty('location')) {
url = headers.location;
}
return JSON.stringify({
parse: 0,
url: url,
});
}
async function search(wd, quick) {
return '{}';
}
export function __jsEvalReturn() {
return {
init: init,
home: home,
homeVod: homeVod,
category: category,
detail: detail,
play: play,
search: search,
};
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化