forked from jadehh/TVSpider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathciliduo.js
191 lines (163 loc) · 5.89 KB
/
ciliduo.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* @File : ciliduo.js
* @Author : jade
* @Date : 2024/3/1 13:26
* @Email : [email protected]
* @Software : Samples
* @Desc : 磁力多
*/
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";
class CiliDuoSpider extends Spider {
constructor() {
super();
this.siteUrl = "https://of.cilido.top"
this.apiUrl = ""
this.vodShortObj = {}
}
getName() {
return "🔞┃磁力多BT┃🔞"
}
getAppName() {
return "磁力多BT"
}
getJSName() {
return "ciliduo"
}
getType() {
return 3
}
getProxy(src) {
return Utils.base64Decode(src)
}
async home(filter) {
try {
await this.jadeLog.info("正在解析首页类别", true)
let $ = await this.getHtml()
let proxy_src = Utils.getStrByRegex(/var proxy = atob\('(.*?)'\)/, $.html())
this.apiUrl = this.getProxy(proxy_src)
let params = `/?host=${Utils.getHost(this.siteUrl).split("://").slice(-1)[0]}&v=1`
let homeContent = await this.fetch(this.apiUrl, params, this.getHeader())
return await this.parseVodShortListFromDoc(load(homeContent))
} catch (e) {
await this.jadeLog.error(`首页解析失败,失败原因为:${e}`)
}
}
async parseVodShortListFromDoc($) {
let rootElemet = $("[class=\"htab\"]")
let navElements = rootElemet.find("a")
let vodElements = $("[class=\"hotwords\"]").find("ul")
for (let i = 0; i < navElements.length; i++) {
let navElement = navElements[i]
if (i !== navElements.length - 1) {
let type_name = $(navElement).text()
if (type_name === "热门") {
type_name = "最近更新"
}
this.classes.push(this.getTypeDic(type_name, type_name))
let vodElement = vodElements[i]
let vod_list = []
for (const vodShorElement of $(vodElement).find("a")) {
let vodShort = new VodShort()
vodShort.vod_id = vodShorElement.attribs.href
vodShort.vod_name = $(vodShorElement).html()
vodShort.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
vod_list.push(vodShort)
}
this.vodShortObj[type_name] = vod_list
}
}
return this.result.home(this.classes, [], this.filterObj)
}
async parseVodShortListFromDocBySearch($) {
let vod_list = []
let vodElements = $("[class=\"ssbox\"]")
for (const vodElement of vodElements.slice(0, -1)) {
let vodShort = new VodShort()
vodShort.vod_id = $(vodElement).find("a")[0].attribs.href
vodShort.vod_name = $($(vodElement).find("a")[0]).text()
vodShort.vod_remarks = $($(vodElement).find("span")[0]).text()
vodShort.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
vod_list.push(vodShort)
}
return vod_list
}
async parseVodDetailFromDoc($) {
let html = $.html()
let vodDetail = new VodDetail()
vodDetail.vod_name = $($("[class=\"bt_title\"]")).text()
vodDetail.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
vodDetail.vod_remarks = Utils.getStrByRegex(/<br>收录时间:<span>(.*?)<\/span>/, $.html())
vodDetail.vod_content = "下载速度:" + Utils.getStrByRegex(/下载速度:<span>(.*?)<\/span>/, $.html())
vodDetail.vod_play_from = ["磁力连接"].join("$$$")
let vodItems = []
let contentElement = $("[class=\"content\"]").find("span")[0]
let episodeUrl = contentElement.attribs.href;
let episodeName = contentElement.attribs.title;
vodItems.push(episodeName + "$" + episodeUrl);
vodDetail.vod_play_url = [vodItems.join("#")].join("$$$")
return vodDetail
}
async setHomeVod() {
this.homeVodList = this.vodShortObj["最近更新"]
}
async setCategory(tid, pg, filter, extend) {
this.vodList = this.vodShortObj[tid]
}
async setDetail(id) {
if (id.indexOf("search") > -1) {
let content = await this.fetch(this.apiUrl + id, null, this.getHeader())
let vod_list = await this.parseVodShortListFromDocBySearch(load(content))
id = vod_list[0].vod_id
}
await this.jadeLog.debug(id)
let detailUrl = this.apiUrl + id
let detailContent = await this.fetch(detailUrl, null, this.getHeader())
this.vodDetail = await this.parseVodDetailFromDoc(load(detailContent))
}
async setSearch(wd, quick) {
let searchUrl = this.apiUrl + `search?word=${wd}`
let content = await this.fetch(searchUrl, null, this.getHeader())
this.vodList = await this.parseVodShortListFromDocBySearch(load(content))
}
}
let spider = new CiliDuoSpider()
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)
}
async function proxy(segments, headers) {
return await spider.proxy(segments, headers)
}
export function __jsEvalReturn() {
return {
init: init,
home: home,
homeVod: homeVod,
category: category,
detail: detail,
play: play,
proxy: proxy,
search: search,
};
}
export {spider}