-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavday_int.js
More file actions
658 lines (603 loc) · 17.3 KB
/
Copy pathjavday_int.js
File metadata and controls
658 lines (603 loc) · 17.3 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
var WidgetMetadata = {
id: "javday_int",
title: "JAVDay",
description: "網路收集到的模塊",
author: "Ti",
site: "https://javday.app",
version: "1.2.0",
requiredVersion: "0.0.1",
detailCacheDuration: 60,
modules: [
// 搜索模块
{
title: "搜索视频",
description: "搜索JAVDay视频库",
requiresWebView: false,
functionName: "search",
cacheDuration: 3600,
params: [
{
name: "keyword",
title: "女優/番號/關鍵字搜索…",
type: "input",
value: "",
description: "女優/番號/關鍵字搜索…",
},
{
name: "page",
title: "页码",
type: "page",
description: "搜索结果页码"
}
]
},
// 最新模块
{
title: "最新更新",
description: "浏览最新更新视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/label/new/"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 人气模块
{
title: "人气系列",
description: "浏览人气系列视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/label/hot/"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 新作模块
{
title: "新作上市",
description: "浏览新作上市视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/new-release/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "new"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 有码模块
{
title: "有码视频",
description: "浏览有码分类视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/censored/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "popular"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 无码模块
{
title: "无码视频",
description: "浏览无码分类视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/uncensored/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "new"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 流出模块
{
title: "无码流出",
description: "浏览无码流出视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/uncensored-leaked/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "new"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 杏吧模块
{
title: "杏吧视频",
description: "浏览杏吧分类视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/sex8/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "popular"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 玩偶模块
{
title: "玩偶姐姐",
description: "浏览玩偶姐姐视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/hongkongdoll/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "popular"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 国产模块
{
title: "国产 AV",
description: "浏览国产 AV视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "列表地址",
type: "constant",
description: "列表地址",
value: "https://javday.app/category/chinese-av/"
},
{
name: "sort_by",
title: "排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
description: "选择视频排序方式",
value: "popular"
},
{
name: "page",
title: "页码",
type: "page"
}
]
},
// 厂商模块
{
title: "国产厂商",
description: "按厂商标签浏览国产厂商视频",
requiresWebView: false,
functionName: "loadPage",
cacheDuration: 3600,
params: [
{
name: "url",
title: "厂商选择",
type: "enumeration",
belongTo: {
paramName: "sort_by",
value: ["new","popular"],
},
enumOptions: [
{ title: "麻豆传媒", value: "https://javday.app/index.php/category/madou/" },
{ title: "果冻传媒", value: "https://javday.app/index.php/category/91zhipianchang/" },
{ title: "天美传媒", value: "https://javday.app/index.php/category/timi/" },
{ title: "星空无限", value: "https://javday.app/index.php/category/xingkong/" },
{ title: "皇家华人", value: "https://javday.app/index.php/category/royalasianstudio/" },
{ title: "蜜桃影像", value: "https://javday.app/index.php/category/mtgw/" },
{ title: "精东影业", value: "https://javday.app/index.php/category/jdav/" },
{ title: "台湾 AV", value: "https://javday.app/index.php/category/twav/" },
{ title: "JVID", value: "https://javday.app/index.php/category/jvid/" },
{ title: "萝莉社", value: "https://javday.app/index.php/category/luolisheus/" },
{ title: "糖心VLOG", value: "https://javday.app/index.php/category/txvlog/" },
{ title: "Psychoporn TW", value: "https://javday.app/index.php/category/psychoporn-tw/" }
],
value: "https://javday.app/index.php/category/madou/",
description: "选择要浏览的厂商"
},
{
name: "sort_by",
title: "🔢 排序方式",
type: "enumeration",
enumOptions: [
{ title: "最新上架", value: "new" },
{ title: "人气最高", value: "popular" }
],
value: "new",
description: "选择视频排序方式"
},
{
name: "page",
title: "页码",
type: "page"
}
]
}
]
};
const JAVDAY_LOG_PREFIX = "ForwardWidget: JAVDay -";
const JAVDAY_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36";
function extractCategoryId(url) {
const match = url.match(/\/([^/]+)\/?$/);
if (match && match[1]) {
return match[1].replace(/\/+$/, '');
}
const parts = url.split('/').filter(part => part.length > 0);
return parts[parts.length - 1] || url.split('/').slice(-2, -1)[0] || 'unknown';
}
function buildPageUrl(baseUrl, sortBy, page) {
const categoryId = extractCategoryId(baseUrl);
const cleanBaseUrl = baseUrl.replace(/index\.php\//g, '');
let path;
if (sortBy === "popular") {
path = `/fiter/by/hits/id/${categoryId}`;
} else {
path = cleanBaseUrl.includes('label/')
? cleanBaseUrl.replace(/\/page\/\d+\/?$/, '')
: `/category/${categoryId}`;
}
if (page > 1) {
return `${path}/page/${page}/`;
}
return `${path}/`;
}
function getFullUrl(path) {
if (path.startsWith("http")) return path;
return `https://javday.app${path}`;
}
function getCoverImgSrc($item) {
const coverElement = $item.find(".videoBox-cover");
const styleAttr = coverElement.attr("style");
if (styleAttr) {
const match = styleAttr.match(/url\(\s*['"]?([^'")]+)['"]?\s*\)/);
if (match && match[1]) {
const extractedUrl = match[1];
if (extractedUrl.startsWith("//")) {
return `https:${extractedUrl}`;
}
if (extractedUrl.startsWith("http")) {
return extractedUrl;
}
return `https://javday.app${extractedUrl.startsWith("/") ? "" : "/"}${extractedUrl}`;
}
}
return "";
}
function extractVideoUrlFromDPlayerScript(scriptContent) {
if (!scriptContent) return null;
const regexes = [
/video\s*:\s*{\s*[^}]*url\s*:\s*['"]([^'"]+)['"]/,
/url\s*:\s*['"]([^'"]+\.m3u8[^'"]*)['"]/
];
for (const regex of regexes) {
const match = scriptContent.match(regex);
if (match && match[1]) return match[1];
}
return null;
}
async function loadPage(params = {}) {
const baseUrl = params.url;
const sortBy = params.sort_by || "new";
const page = parseInt(params.page, 10) || 1;
const pagePath = buildPageUrl(baseUrl, sortBy, page);
const targetUrl = getFullUrl(pagePath);
try {
const response = await Widget.http.get(targetUrl, {
headers: {
"User-Agent": JAVDAY_USER_AGENT,
Referer: "https://javday.app/",
},
});
if (!response?.data) {
throw new Error("无法获取页面内容");
}
const $ = Widget.html.load(response.data);
const videoItems = [];
$(".video-wrapper .videoBox").each((index, element) => {
const $item = $(element);
let link = $item.attr("href");
const title = $item.find(".videoBox-info .title").text().trim();
const imgSrc = getCoverImgSrc($item);
if (!link || !title) return;
if (!link.startsWith("http")) {
link = link.startsWith("//")
? `https:${link}`
: `https://javday.app${link.startsWith("/") ? "" : "/"}${link}`;
}
link = link.replace(/([^:]\/)\/+/g, '$1');
videoItems.push({
id: `${index}|${link}`,
type: "url",
title: title,
imgSrc: imgSrc,
backdropPath: imgSrc,
link: link,
description: `来自JAVDay | 排序:${sortBy === "new" ? "最新上架" : "人气最高"}`,
mediaType: "movie",
});
});
return videoItems;
} catch (error) {
console.error(`${JAVDAY_LOG_PREFIX} 获取视频失败: ${error.message}`);
throw error;
}
}
async function search(params = {}) {
const keyword = params.keyword || "";
const page = parseInt(params.page, 10) || 1;
if (!keyword) {
throw new Error("请输入搜索关键词");
}
let searchUrl;
if (page === 1) {
searchUrl = `https://javday.app/search/?wd=${keyword}`;
} else {
searchUrl = `https://javday.app/search/page/${page}/wd/${keyword}/`;
}
try {
const response = await Widget.http.get(searchUrl, {
headers: {
"User-Agent": JAVDAY_USER_AGENT,
Referer: "https://javday.app/",
},
});
if (!response?.data) {
throw new Error("无法获取搜索结果");
}
const $ = Widget.html.load(response.data);
const videoItems = [];
$(".video-wrapper .videoBox").each((index, element) => {
const $item = $(element);
let link = $item.attr("href");
const title = $item.find(".videoBox-info .title").text().trim();
const imgSrc = getCoverImgSrc($item);
if (!link || !title) return;
if (!link.startsWith("http")) {
link = link.startsWith("//")
? `https:${link}`
: `https://javday.app${link.startsWith("/") ? "" : "/"}${link}`;
}
link = link.replace(/([^:]\/)\/+/g, '$1');
videoItems.push({
id: `${index}|${link}`,
type: "url",
title: title,
imgSrc: imgSrc,
backdropPath: imgSrc,
link: link,
description: `搜索: ${params.keyword}`,
mediaType: "movie",
});
});
return videoItems;
} catch (error) {
console.error(`${JAVDAY_LOG_PREFIX} 搜索失败: ${error.message}`);
throw error;
}
}
async function loadDetail(link) {
try {
const response = await Widget.http.get(link, {
headers: {
"User-Agent": JAVDAY_USER_AGENT,
Referer: link,
},
});
if (!response?.data) {
throw new Error("无法获取详情页内容");
}
const $ = Widget.html.load(response.data);
const dplayerScript = Array.from($("script"))
.find(el => {
const scriptContent = $(el).html();
return scriptContent && scriptContent.includes("new DPlayer");
});
if (dplayerScript) {
const scriptContent = $(dplayerScript).html();
const videoUrl = extractVideoUrlFromDPlayerScript(scriptContent);
if (videoUrl) {
return {
id: link,
type: "url",
videoUrl: videoUrl,
customHeaders: {
Referer: link,
"User-Agent": JAVDAY_USER_AGENT,
},
};
}
}
const videoSrc = $("video#J_prismPlayer").attr("src") ||
$("source[src*='.m3u8']").attr("src") ||
$("video source").attr("src");
if (videoSrc) {
return {
id: link,
type: "url",
videoUrl: videoSrc,
customHeaders: {
Referer: link,
"User-Agent": JAVDAY_USER_AGENT,
},
};
}
const scriptSources = Array.from($("script"))
.map(el => $(el).html())
.find(content => content && content.includes(".m3u8"));
if (scriptSources) {
const m3u8Match = scriptSources.match(/['"](https?:\/\/[^'"]+\.m3u8[^'"]*)['"]/);
if (m3u8Match && m3u8Match[1]) {
return {
id: link,
type: "url",
videoUrl: m3u8Match[1],
customHeaders: {
Referer: link,
"User-Agent": JAVDAY_USER_AGENT,
},
};
}
}
const playerVideo = $("video[src]").attr("src") ||
$("iframe[src*='player']").attr("src");
if (playerVideo) {
return {
id: link,
type: "url",
videoUrl: playerVideo,
customHeaders: {
Referer: link,
"User-Agent": JAVDAY_USER_AGENT,
},
};
}
throw new Error("无法找到视频源");
} catch (error) {
console.error(`${JAVDAY_LOG_PREFIX} 加载详情失败: ${error.message}`);
throw error;
}
}