update CAT

This commit is contained in:
qist
2024-04-17 11:16:03 +08:00
parent 14f58c87f5
commit 4ce167269d
17 changed files with 855 additions and 369 deletions
+10 -3
View File
@@ -99,7 +99,7 @@ class BilibiliSpider extends Spider {
for (const navElement of navElements) {
this.classes.push(this.getTypeDic($(navElement).text(), $(navElement).text()))
}
if (!_.isEmpty(this.bili_jct)) {
if (!_.isEmpty(this.bili_jct) && this.is_login) {
this.classes.push(this.getTypeDic("历史记录", "历史记录"))
}
}
@@ -402,12 +402,19 @@ class BilibiliSpider extends Spider {
this.vodList = await this.parseVodShortListFromJson(items)
}
async setSearch(wd, quick) {
async setSearch(wd, quick, pg) {
const ext = {
duration: '0',
};
let resp = JSON.parse(await this.category(wd, 1, true, ext));
let page = parseInt(pg)
const limit = 20
let resp = JSON.parse(await this.category(wd, page, true, ext));
this.vodList = resp["list"]
let pageCount = page;
if (this.vodList.length === limit) {
pageCount = page + 1;
}
this.result.setPage(page, pageCount, limit, pageCount)
}
getDashMedia(dash) {
-1
View File
@@ -11,7 +11,6 @@ import {_, load} from '../lib/cat.js';
import {VodDetail, VodShort} from "../lib/vod.js"
import * as Utils from "../lib/utils.js";
import {Spider} from "./spider.js";
import {detailContent} from "../lib/ali.js";
class CiliDuoSpider extends Spider {
+16 -6
View File
@@ -492,6 +492,7 @@ class DoubanSpider extends Spider {
let raw_sign = [method.toLocaleUpperCase(), url_path, ts.toString()].join("&")
return Crypto.HmacSHA1(raw_sign, _api_secret_key).toString(Crypto.enc.Base64)
}
async setHomeVod() {
let url = this.siteUrl + "/subject_collection/subject_real_time_hotest/items"
let content = await this.fetch(url, {"apikey": this.apiKey}, this.getHeader())
@@ -510,8 +511,8 @@ class DoubanSpider extends Spider {
this.limit = 20;
this.total = 0;
let start = 0
if (parseInt(pg) > 1){
start = (parseInt(pg) - 1) * this.limit
if (parseInt(pg) > 1) {
start = (parseInt(pg) - 1) * this.limit
}
let cateUrl = ""
let params = {"start": start.toString(), "count": this.limit.toString()}
@@ -565,25 +566,33 @@ class DoubanSpider extends Spider {
this.vodList = await this.parseVodShortListFromJson(items)
}
}
async setSearch(wd, quick) {
async setSearch(wd, quick, pg) {
let _api_url = "https://frodo.douban.com/api/v2"
let _api_key = "0dad551ec0f84ed02907ff5c42e8ec70"
let url = _api_url + "/search/movie"
let date = new Date()
let ts = date.getFullYear().toString() + (date.getMonth() + 1).toString() + date.getDate().toString()
let ts = date.getFullYear().toString() + ('0' + (date.getMonth() + 1)).slice(-2).toString() + date.getDate().toString()
const limit = 20
let params = {
'_sig': this.sign(url, ts),
'_ts': ts,
'apiKey': _api_key,
'count': 20,
'count': limit,
'os_rom': 'android',
'q': encodeURIComponent(wd),
'start': 0
'start': parseInt(pg)
}
let content = await this.fetch(url, params, this.getSearchHeader())
if (!_.isEmpty(content)) {
let content_json = JSON.parse(content)
this.vodList = await this.parseVodShortListFromJson(content_json["items"])
const page = parseInt(pg);
let pageCount = page;
if (this.vodList.length === limit) {
pageCount = page + 1;
}
this.result.setPage(page, pageCount, limit, pageCount)
}
}
}
@@ -623,4 +632,5 @@ export function __jsEvalReturn() {
init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
};
}
export {spider}
+75
View File
@@ -0,0 +1,75 @@
/*
* @File : dubo.js
* @Author : jade
* @Date : 2024/4/16 18:46
* @Email : [email protected]
* @Software : Samples
* @Desc :
*/
import {TianTianSpider} from "./tiantian.js"
class DuboSpider extends TianTianSpider {
constructor() {
super();
this.siteUrl = "http://v.rbotv.cn"
this.cookie = ""
this.extendObj = {"extend": "类型", "area": "地区", "lang": "语言", "year": "年代"}
this.parseMap = {};
}
getName() {
return "🛶┃独播影视┃🛶"
}
getAppName() {
return "独播影视"
}
getJSName() {
return "dubo"
}
getType() {
return 3
}
async init(cfg) {
await super.init(cfg);
this.danmuStaus = false
}
}
let spider = new DuboSpider()
async function init(cfg) {
await spider.init(cfg)
}
async function home(filter) {
return await spider.home(filter)
}
async function homeVod() {
return await spider.homeVod()
}
async function category(tid, pg, filter, extend) {
return await spider.category(tid, pg, filter, extend)
}
async function detail(id) {
return await spider.detail(id)
}
async function play(flag, id, flags) {
return await spider.play(flag, id, flags)
}
async function search(wd, quick) {
return await spider.search(wd, quick)
}
export function __jsEvalReturn() {
return {
init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
};
}
export {spider}
+44 -17
View File
@@ -9,7 +9,7 @@
import {Crypto, jinja2, _} from "../lib/cat.js";
import {Spider} from "./spider.js";
import {VodDetail, VodShort} from "../lib/vod.js";
import * as Utils from "../lib/utils.js";
function stripHtmlTag(src) {
return src
.replace(/<\/?[^>]+(>|$)/g, '')
@@ -89,7 +89,10 @@ class NanGuaSpider extends Spider {
}, {
"key": "year",
"name": "年份",
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {
"n": "2023",
"v": "2023"
}, {"n": "2022", "v": "2022"}, {
"n": "2021", "v": "2021"
}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {
"n": "2017", "v": "2017"
@@ -117,7 +120,10 @@ class NanGuaSpider extends Spider {
}, {
"key": "year",
"name": "年份",
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {
"n": "2023",
"v": "2023"
}, {"n": "2022", "v": "2022"}, {
"n": "2021", "v": "2021"
}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {
"n": "2017", "v": "2017"
@@ -141,7 +147,10 @@ class NanGuaSpider extends Spider {
}, {
"key": "year",
"name": "年份",
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {
"n": "2023",
"v": "2023"
}, {"n": "2022", "v": "2022"}, {
"n": "2021", "v": "2021"
}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {
"n": "2017", "v": "2017"
@@ -169,7 +178,10 @@ class NanGuaSpider extends Spider {
}, {
"key": "year",
"name": "年份",
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {
"n": "2023",
"v": "2023"
}, {"n": "2022", "v": "2022"}, {
"n": "2021", "v": "2021"
}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {
"n": "2017", "v": "2017"
@@ -193,7 +205,10 @@ class NanGuaSpider extends Spider {
}, {
"key": "year",
"name": "年份",
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"}, {"n": "2022", "v": "2022"}, {
"value": [{"n": "全部", "v": "年份"}, {"n": "2024", "v": "2024"}, {
"n": "2023",
"v": "2023"
}, {"n": "2022", "v": "2022"}, {
"n": "2021", "v": "2021"
}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {
"n": "2017", "v": "2017"
@@ -208,9 +223,9 @@ class NanGuaSpider extends Spider {
};
}
async parseVodShortListFromJSONByHome(obj){
async parseVodShortListFromJSONByHome(obj) {
let vod_list = []
for (const data of obj["video"]){
for (const data of obj["video"]) {
let video_vod_list = await this.parseVodShortListFromJson(data["data"])
vod_list.push(...video_vod_list)
}
@@ -219,13 +234,13 @@ class NanGuaSpider extends Spider {
async parseVodShortListFromJson(obj) {
let vod_list = []
for (const data of obj){
for (const data of obj) {
let vodShort = new VodShort()
vodShort.vod_id = data["id"]
vodShort.vod_name = data["name"]
vodShort.vod_pic = data["img"]
vodShort.vod_remarks = data["remarks"]
if (_.isEmpty(vodShort.vod_remarks)){
if (_.isEmpty(vodShort.vod_remarks)) {
vodShort.vod_remarks = data["msg"]
}
vod_list.push(vodShort)
@@ -236,11 +251,15 @@ class NanGuaSpider extends Spider {
async parseVodShortListFromJsonBySearch(obj) {
let videos = [];
obj.forEach(function (it) {
videos.push({
vod_id: it.id, vod_name: it["video_name"], vod_pic: it.img, vod_remarks: it["qingxidu"] + '/' + it.category,
});
});
for (const data of obj){
let vodShort = new VodShort()
vodShort.vod_id = data["id"]
vodShort.vod_name = data["video_name"]
vodShort.vod_remarks = data["qingxidu"]
vodShort.vod_pic = Utils.formatUrl(data["img"])
videos.push(vodShort)
}
return videos
}
@@ -299,9 +318,16 @@ class NanGuaSpider extends Spider {
this.vodDetail = await this.parseVodDetailfromJson(data)
}
async setSearch(wd, quick) {
let data = JSON.parse(await this.fetch(this.siteUrl + '/api.php/provide/search_result_more?app=ylys&video_name=' + wd + '&pageSize=20&tid=0&imei=c431ea542cee9679&page=0', null, this.getHeader())).data;
async setSearch(wd, quick, pg) {
let page = parseInt(pg)
const limit = 20
let data = JSON.parse(await this.fetch(this.siteUrl + '/api.php/provide/search_result_more?app=ylys&video_name=' + wd + `&pageSize=${limit}&tid=0&imei=c431ea542cee9679&page=${pg}`, null, this.getHeader())).data;
this.vodList = await this.parseVodShortListFromJsonBySearch(data)
let pageCount = page;
if (this.vodList.length === limit) {
pageCount = page + 1;
}
this.result.setPage(page, pageCount, limit, pageCount)
}
async setPlay(flag, id, flags) {
@@ -359,4 +385,5 @@ export function __jsEvalReturn() {
init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
};
}
export {spider}
+1 -1
View File
@@ -681,7 +681,7 @@ class Spider {
async search(wd, quick) {
this.vodList = []
await this.jadeLog.info(`正在解析搜索页面,关键词为 = ${wd},quick = ${quick}`)
await this.setSearch(wd, quick)
await this.setSearch(wd, quick,1)
if (this.vodList.length === 0) {
if (wd.indexOf(" ") > -1) {
await this.jadeLog.debug(`搜索关键词为:${wd},其中有空格,去除空格在搜索一次`)
+11 -6
View File
@@ -55,9 +55,9 @@ async function test() {
await spider.init({
skey: siteKey, stype: siteType, ext: {
"token": "6827db23e5474d02a07fd7431d3d5a5a",
"box": "bilibili",
"box": "TV",
"code": "1",
"from": "justlive1",
"from": "bilibili",
"danmu": true,
"cookie": "buvid3=02675249-8ED3-C418-87F5-59E18316459714816infoc; b_nut=1704421014; _uuid=5D435F74-F574-D9AB-62C1-B9294DE465D913102infoc; buvid_fp=e8c5650c749398e9b5cad3f3ddb5081e; buvid4=007E85D1-52C1-7E6E-07CF-837FFBC9349516677-024010502-J5vTDSZDCw4fNnXRejbSVg%3D%3D; rpdid=|()kYJmulRu0J'u~|RRJl)JR; PVID=1; SESSDATA=3be091d3%2C1720332009%2C699ed%2A11CjAcCdwXG5kY1umhCOpQHOn_WP7L9xFBfWO7KKd4BPweodpR6VyIfeNyPiRmkr5jCqsSVjg0R0dZOVVHRUo3RnhPRTZFc3JPbGdiUjFCdHpiRDhiTkticmdKTjVyS1VhbDdvNjFMSDJlbUJydUlRdjFUNGFBNkJlV2ZTa0N1Q1BEVi1QYTQzTUh3IIEC; bili_jct=b0ee7b5d3f27df893545d811d95506d4; DedeUserID=78014638; DedeUserID__ckMd5=4c8c5d65065e468a; enable_web_push=DISABLE; header_theme_version=CLOSE; home_feed_column=5; CURRENT_BLACKGAP=0; CURRENT_FNVAL=4048; b_lsid=75E916AA_18EA1A8D995; bsource=search_baidu; FEED_LIVE_VERSION=V_HEADER_LIVE_NO_POP; browser_resolution=1507-691; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTIzNjk5MTMsImlhdCI6MTcxMjExMDY1MywicGx0IjotMX0.8zQW_fNTCSBlK_JkHnzu3gDw62wuTK1qgKcbGec3swM; bili_ticket_expires=171236985"
}
@@ -68,25 +68,30 @@ async function test() {
console.debug(JSON.stringify(classes))
// //测试首页列表
let homeVod = JSON.parse(await spider.homeVod())
console.debug(JSON.stringify(homeVod));
// 测试搜索
let search_page = JSON.parse(await spider.search("王牌",false,2))
console.debug(JSON.stringify(search_page))
// 测试详情
let detail1 = JSON.parse(await spider.detail("BV1Pp421R7pn"))
let detail1 = JSON.parse(await spider.detail("86534"))
await testPlay(detail1)
;
let catePage = JSON.parse(await spider.category("2", "1", undefined, {}));
console.debug(JSON.stringify(catePage));
// 测试搜索
let search_page = JSON.parse(await spider.search("王牌"))
console.debug(JSON.stringify(search_page));
+277
View File
@@ -0,0 +1,277 @@
/*
* @File : tiantian.js
* @Author : jade
* @Date : 2024/04/15 10:48
* @Email : [email protected]
* @Software : Samples
* @Desc : 天天影视
*/
import {Spider} from "./spider.js";
import {_} from "../lib/cat.js";
import * as Utils from "../lib/utils.js";
import {VodDetail, VodShort} from "../lib/vod.js";
class TianTianSpider extends Spider {
constructor() {
super();
this.siteUrl = "http://op.ysdqjs.cn"
this.cookie = ""
this.extendObj = {"extend": "类型", "area": "地区", "lang": "语言", "year": "年代"}
this.parseMap = {};
}
async request(reqUrl, method, data) {
const headers = {
'User-Agent': Utils.CHROME,
};
if (!_.isEmpty(this.cookie)) {
headers['Cookie'] = this.cookie;
}
const postType = method === 'post' ? 'form-data' : '';
let res = await req(reqUrl, {
method: method || 'get', headers: headers, data: data, postType: postType,
});
if (res.code === 403) {
const path = res.data.match(/window\.location\.href ="(.*?)"/)[1];
this.cookie = _.isArray(res.headers['set-cookie']) ? res.headers['set-cookie'].join(';') : res.headers['set-cookie'];
headers['Cookie'] = this.cookie;
res = await req(this.siteUrl + path, {
method: method || 'get', headers: headers, data: data, postType: postType,
});
}
return res.content;
}
async postData(url, data) {
const timestamp = Math.floor(new Date().getTime() / 1000);
const key = 'kj5649ertj84ks89r4jh8s45hf84hjfds04k';
const sign = md5X(key + timestamp).toString();
let defaultData = {
sign: sign, timestamp: timestamp,
};
const reqData = data ? _.merge(defaultData, data) : defaultData;
return await this.request(url, 'post', reqData);
}
getName() {
return "⛄┃天天影视┃⛄"
}
getAppName() {
return "天天影视"
}
getJSName() {
return "tiantian"
}
getType() {
return 3
}
async init(cfg) {
await super.init(cfg);
this.danmuStaus = false
}
generateParam(tid, pg, extend, limit) {
const param = {
type_id: tid, page: pg, limit: limit,
};
if (extend.class) {
param.class = extend.class;
}
if (extend.area) {
param.area = extend.area;
}
if (extend.lang) {
param.lang = extend.lang;
}
if (extend.year) {
param.year = extend.year;
}
// if (extend.order) {
// param.order = extend.order;
// }
return param;
}
async getFilter(data) {
let extend_list = []
Object.keys(data).forEach(key => {
if (Array.isArray(data[key])) {
let extend_dic = {"key": key, "name": this.extendObj[key], "value": []}
for (const extend_data of data[key]) {
extend_dic["value"].push({"n": extend_data, "v": extend_data})
}
extend_list.push(extend_dic)
}
})
return extend_list
}
async setClasses() {
let resJson = JSON.parse(await this.postData(this.siteUrl + '/v2/type/top_type'))
for (const data of resJson["data"]["list"]) {
let type_name = data["type_name"]
let type_id = data["type_id"].toString()
this.classes.push(this.getTypeDic(type_name, type_id))
this.filterObj[type_id] = await this.getFilter(data)
}
}
async parseVodShortListFromJson(vodList) {
let vod_list = []
for (const vodData of vodList) {
let vodShort = new VodShort()
vodShort.load_data(vodData)
if (_.isEmpty(vodShort.vod_pic) && vodData["vod_pic_thumb"] !== undefined){
vodShort.vod_pic = vodData["vod_pic_thumb"]
}
if (vodShort.vod_name !== "首页轮播"){
vod_list.push(vodShort)
}
}
return vod_list
}
async parseVodDetailfromJson(detailObj) {
let vodDetail = new VodDetail()
vodDetail.load_data(detailObj)
vodDetail.vod_content = Utils.formatContent(vodDetail.vod_content)
const playInfo = detailObj["vod_play_list"];
const playVod = {};
_.each(playInfo, (obj) => {
const sourceName = obj.name;
let playList = '';
const videoInfo = obj.urls;
const parse = obj["parse_urls"];
if (!_.isEmpty(parse)) this.parseMap[sourceName] = parse;
const vodItems = _.map(videoInfo, (epObj) => {
const epName = epObj.name;
const playUrl = epObj.url;
return epName + '$' + playUrl;
});
if (_.isEmpty(vodItems)) return;
playList = vodItems.join('#');
playVod[sourceName] = playList;
});
vodDetail.vod_play_from = _.keys(playVod).join('$$$');
vodDetail.vod_play_url = _.values(playVod).join('$$$');
return vodDetail
}
async setHomeVod() {
let resJson = JSON.parse(await this.postData(this.siteUrl + '/v2/type/tj_vod'))
let vod_list = []
for (const data of resJson["data"]["type_vod"]) {
if (data["type_name"] !== "广告") {
vod_list = await this.parseVodShortListFromJson(data["vod"])
this.homeVodList = [...this.homeVodList,...vod_list]
}
}
vod_list = await this.parseVodShortListFromJson(resJson["data"]["loop"])
this.homeVodList = [...this.homeVodList,...vod_list]
vod_list = await this.parseVodShortListFromJson(resJson["data"]["cai"])
this.homeVodList = [...this.homeVodList,...vod_list]
}
async setCategory(tid, pg, filter, extend) {
const limit = 12;
const param = this.generateParam(tid, pg, extend, limit);
const resJson = JSON.parse(await this.postData(this.siteUrl + '/v2/home/type_search', param));
this.vodList = await this.parseVodShortListFromJson(resJson["data"]["list"])
}
async setDetail(id) {
const param = {
vod_id: id,
}
const resJson = JSON.parse(await this.postData(this.siteUrl + '/v2/home/vod_details', param));
this.vodDetail = await this.parseVodDetailfromJson(resJson["data"])
}
async setPlay(flag, id, flags) {
const parsers = this.parseMap[flag];
if (flag.indexOf("芒果") > -1 || flag.indexOf("腾讯") > -1 || flag.indexOf("爱奇艺") > -1) {
this.danmuStaus = true
if (!this.catOpenStatus) {
this.danmuUrl = await this.danmuSpider.downloadDanmu("https://dmku.thefilehosting.com/?ac=dm&url=" + id)
}
}
if (!_.isEmpty(parsers)) {
for (const parser of parsers) {
if (_.isEmpty(parser)) continue;
try {
const resp = await this.request(parser + id);
const json = JSON.parse(resp);
if (!_.isEmpty(json.url)) {
this.playUrl = json.url;
break;
}
} catch (e) {
}
}
}
}
async setSearch(wd, quick, pg) {
const limit = 12;
const param = {
keyword: wd, page: pg, limit: limit,
};
const resJson = JSON.parse(await this.postData(this.siteUrl + '/v2/home/search', param));
this.vodList = await this.parseVodShortListFromJson(resJson["data"]["list"])
const page = parseInt(pg);
let pageCount = page;
if (this.vodList.length === limit) {
pageCount = page + 1;
}
this.result.setPage(page, pageCount, limit, pageCount)
}
}
let spider = new TianTianSpider()
async function init(cfg) {
await spider.init(cfg)
}
async function home(filter) {
return await spider.home(filter)
}
async function homeVod() {
return await spider.homeVod()
}
async function category(tid, pg, filter, extend) {
return await spider.category(tid, pg, filter, extend)
}
async function detail(id) {
return await spider.detail(id)
}
async function play(flag, id, flags) {
return await spider.play(flag, id, flags)
}
async function search(wd, quick) {
return await spider.search(wd, quick)
}
export function __jsEvalReturn() {
return {
init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
};
}
export {spider, TianTianSpider}
+10 -2
View File
@@ -69,8 +69,16 @@ class VodSpider extends Spider {
vodDetail.vod_director = vod_data["vod_director"]
let $ = load(vod_data['vod_content'])
vodDetail.vod_content = $.text()
vodDetail.vod_play_from = vod_data["vod_play_from"]
vodDetail.vod_play_url = vod_data["vod_play_url"]
if (vod_data["vod_down_url"] !== undefined) {
if (vod_data["vod_down_url"].length > 0) {
vodDetail.vod_play_from = "直链播放$$$"
vodDetail.vod_play_url = vod_data["vod_down_url"] + "$$$"
}
}
vodDetail.vod_play_from = vodDetail.vod_play_from + vod_data["vod_play_from"]
vodDetail.vod_play_url = vodDetail.vod_play_url + vod_data["vod_play_url"]
vodDetail.type_name = vod_data["type_name"]
return vodDetail
}