diff --git a/js/茶杯狐.js b/js/茶杯狐.js new file mode 100644 index 0000000..cabbd93 --- /dev/null +++ b/js/茶杯狐.js @@ -0,0 +1,543 @@ +/* +@header({ + searchable: 1, + filterable: 1, + quickSearch: 1, + title: '茶杯狐', + lang: 'cat' +}) +*/ + +const API_HOST = 'http://www.bnjxjd.com'; + +const HEADERS = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', + 'accept-language': 'zh-CN,zh;q=0.9', + 'Referer': 'http://www.bnjxjd.com/', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', +}; + +// ============ 工具函数 ============ + +async function fetchHtml(url) { + try { + const res = await req(url, { headers: HEADERS }); + return res.content || ''; + } catch (e) { + return ''; + } +} + +function cleanHtml(text) { + if (!text) return ''; + return text.replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim(); +} + +function fixUrl(url) { + if (!url) return ''; + if (url.startsWith('//')) return 'https:' + url; + if (url.startsWith('http')) return url; + if (url.startsWith('/')) return API_HOST + url; + return API_HOST + '/' + url; +} + +// ============ 解析视频列表 ============ + +function parseVideoList(html) { + const videos = []; + if (!html) return videos; + + // 使用正则匹配 stui-vodlist__box 或 stui-vodlist__item + const itemPattern = /
]*class="col-pd"[^>]*>([\s\S]*?)<\/p>/);
+ }
+ if (descMatch) {
+ info.vod_content = cleanHtml(descMatch[1].replace(/<[^>]+>/g, ''));
+ } else {
+ info.vod_content = '';
+ }
+
+ // 海报
+ let picMatch = html.match(/]*class="img-responsive"[^>]*src="([^"]+)"/);
+ if (!picMatch) {
+ picMatch = html.match(/
]*src="([^"]+)"[^>]*class="[^"]*lazy[^"]*"/);
+ }
+ info.vod_pic = picMatch ? fixUrl(picMatch[1]) : '';
+
+ // 演员
+ const actorMatch = html.match(/主演:<\/span>([\s\S]*?)<\/p>/);
+ info.vod_actor = actorMatch ? cleanHtml(actorMatch[1].replace(/<[^>]+>/g, '')) : '';
+
+ // 导演
+ const directorMatch = html.match(/导演:<\/span>([\s\S]*?)<\/p>/);
+ info.vod_director = directorMatch ? cleanHtml(directorMatch[1].replace(/<[^>]+>/g, '')) : '';
+
+ // 地区
+ const areaMatch = html.match(/地区:<\/span>([\s\S]*?)<\/p>/);
+ info.vod_area = areaMatch ? cleanHtml(areaMatch[1].replace(/<[^>]+>/g, '')) : '';
+
+ // 年份
+ const yearMatch = html.match(/年份:<\/span>([\s\S]*?)<\/p>/);
+ info.vod_year = yearMatch ? cleanHtml(yearMatch[1].replace(/<[^>]+>/g, '')) : '';
+
+ // 类型
+ const typeMatch = html.match(/类型:<\/span>([\s\S]*?)<\/p>/);
+ info.type_name = typeMatch ? cleanHtml(typeMatch[1].replace(/<[^>]+>/g, '')) : '';
+
+ // ========== 提取播放列表 ==========
+ const playFrom = [];
+ const playUrls = [];
+
+ // 提取线路名称
+ const tabs = [];
+ const tabPattern = /
]*class="stui-content__playlist[^"]*"[^>]*>([\s\S]*?)<\/ul>/g;
+ const ulMatches = [];
+ let ulMatch;
+ while ((ulMatch = ulPattern.exec(html)) !== null) {
+ ulMatches.push(ulMatch[1]);
+ }
+
+ for (let idx = 0; idx < ulMatches.length; idx++) {
+ const ulContent = ulMatches[idx];
+ const liPattern = /