Skip to content

Commit fe12e24

Browse files
author
Taois
committed
feat:新增另类写法的cat源支持
1 parent 4a0664f commit fe12e24

File tree

7 files changed

+1792
-5
lines changed

7 files changed

+1792
-5
lines changed

libs/catvod.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ const category = async function (filePath, env, tid, pg = 1, filter = 1, extend
184184
const detail = async function (filePath, env, ids) {
185185
const moduleObject = await init(filePath, env);
186186
const vod_id = Array.isArray(ids) ? ids[0] : ids;
187-
return json2Object(await moduleObject.detail(vod_id));
187+
let detailResult = '{}';
188+
// console.log('type of detailContent:', typeof moduleObject.detailContent);
189+
if (moduleObject.detailContent) { // tvbox形式猫源二级参数传ids列表
190+
detailResult = await moduleObject.detailContent(ids);
191+
} else { // ds/cat传非id
192+
detailResult = await moduleObject.detail(vod_id);
193+
}
194+
return json2Object(detailResult);
188195
}
189196

190-
191197
const search = async function (filePath, env, wd, quick = 0, pg = 1) {
192198
const moduleObject = await init(filePath, env);
193199
return json2Object(await moduleObject.search(wd, quick, pg));

libs_drpy/drpyInject.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ async function request(url, opt = {}) {
163163
let effectivePostType = postType;
164164
if (!effectivePostType) {
165165
// 查找不区分大小写的 Content-Type 头
166-
const contentTypeKey = Object.keys(headers).find(key =>
166+
const contentTypeKey = Object.keys(headers).find(key =>
167167
key.toLowerCase() === 'content-type'
168168
);
169-
169+
170170
if (contentTypeKey && headers[contentTypeKey]) {
171171
const contentType = headers[contentTypeKey].toLowerCase();
172172
if (contentType.includes('application/x-www-form-urlencoded')) {
@@ -176,7 +176,7 @@ async function request(url, opt = {}) {
176176
}
177177
}
178178
}
179-
179+
180180
// 根据有效的 postType 处理数据
181181
if (effectivePostType === 'form' && data != null && typeof data === 'object') {
182182
data = qs.stringify(data, {encode: false});
@@ -724,4 +724,48 @@ globalThis.jsonToCookie = jsonToCookie;
724724
globalThis.cookieToJson = cookieToJson;
725725
globalThis.keysToLowerCase = keysToLowerCase;
726726

727+
class BaseSpider {
728+
constructor() {
729+
this.home = this.homeContent;
730+
this.category = this.categoryContent;
731+
// this.detail = this.detailContent;
732+
this.search = this.searchContent;
733+
this.play = this.playerContent;
734+
this.homeVod = this.homeVideoContent;
735+
this.proxy = this.localProxy;
736+
}
737+
738+
async fetch(url, options) {
739+
const content = (await req(url, options)).content;
740+
return {data: content.parseX};
741+
}
742+
743+
async homeContent() {
744+
}
745+
746+
async categoryContent() {
747+
}
748+
749+
async detailContent() {
750+
}
751+
752+
async searchContent() {
753+
}
754+
755+
async playerContent() {
756+
}
757+
758+
async homeVideoContent() {
759+
}
760+
761+
async localProxy() {
762+
763+
}
764+
765+
async action() {
766+
767+
}
768+
}
769+
770+
globalThis.BaseSpider = BaseSpider;
727771
export default {};

0 commit comments

Comments
 (0)