-
Notifications
You must be signed in to change notification settings - Fork 17
/
115RenamePlus.js
1072 lines (1041 loc) · 37.1 KB
/
115RenamePlus.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
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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name 115RenamePlus
// @namespace https://github.com/LSD08KM/115RenamePlus
// @version 0.8.10 格式化视频分段 4K 增加icon
// @description 115RenamePlus(根据现有的文件名<番号>查询并修改文件名)
// @author db117, FAN0926, LSD08KM
// @include https://115.com/*
// @domain javbus.com
// @domain fanbus.blog
// @domain busdmm.club
// @domain seedmm.blog
// @domain avmoo.com
// @domain avmoo.click
// @domain avsox.website
// @domain adult.contents.fc2.com
// @domain mgstage.com
// @grant GM_notification
// @grant GM_xmlhttpRequest
// ==/UserScript==
/*
* @param suffix 后缀,就是扩展名
*/
(function () {
// 按钮
let rename_list = `
<li id="rename_list">
<a id="rename_video_avmoo_javbus" class="mark" href="javascript:;"><i class="icon-operate ifo-video-play"></i><span>视频改名avmoo+javbus</span></a>
<a id="rename_video_avmoo" class="mark" href="javascript:;"><i class="icon-operate ifo-video-play"></i><span>视频改名avmoo</span></a>
<a id="rename_video_javbus" class="mark" href="javascript:;"><i class="icon-operate ifo-video-play"></i><span>视频改名javbus</span></a>
<a id="rename_video_FC2" class="mark" href="javascript:;"><i class="icon-operate ifo-video-play"></i><span>视频改名FC2</span></a>
<a id="rename_video_mgstage" class="mark" href="javascript:;"><i class="icon-operate ifo-video-play"></i><span>视频改名mgstage</span></a>
<!--
<a id="rename_video_javbus_detail" class="mark" href="javascript:;"><i class="icon-operate ifo-linktask"></i><span>视频改名javbus详情页</span></a>
<a id="rename_picture_avmoo" class="mark" href="javascript:;"><i class="icon-operate ifo-cover"></i><span>图片改名avmoo</span></a>
<a id="rename_picture_javbus" class="mark" href="javascript:;"><i class="icon-operate ifo-cover"></i><span>图片改名javbus</span></a>
<a id="rename_picture_FC2" class="mark" href="javascript:;"><i class="icon-operate ifo-cover"></i><span>图片改名FC2</span></a>
<a id="rename_picture_mgstage" class="mark" href="javascript:;"><i class="icon-operate ifo-cover"></i><span>图片改名mgstage</span></a>
-->
</li>
`;
/**
* 添加按钮的定时任务
*/
let interval = setInterval(buttonInterval, 1000);
// javbus
let javbusBase = "https://www.javbus.com/";
// 有码
let javbusSearch = javbusBase + "search/";
// 无码
let javbusUncensoredSearch = javbusBase + "uncensored/search/";
// avmoo
// 有码
let avmooSearch = "https://avmoo.click/cn/search/";
// 无码
let avmooUncensoredSearch = "https://avsox.website/cn/search/";
//FC2
let Fc2Search = "https://adult.contents.fc2.com/article/";
//mgstage
let mgstageSearch = "https://www.mgstage.com/product/product_detail/";
'use strict';
/**
* 添加按钮定时任务(检测到可以添加时添加按钮)
*/
function buttonInterval() {
let open_dir = $("div#js_float_content li[val='open_dir']");
if (open_dir.length !== 0 && $("li#rename_list").length === 0) {
open_dir.before(rename_list);
$("a#rename_video_avmoo").click(
function () {
rename(renameAvmoo, "avmoo", "video", true);
});
$("a#rename_video_javbus").click(
function () {
rename(renameJavbus, "javbus", "video", true);
});
$("a#rename_video_FC2").click(
function () {
rename(renameFc2, "fc2", "video", true);
});
$("a#rename_video_mgstage").click(
function () {
rename(renameMgstage, "mgstage", "video", true);
});
$("a#rename_video_avmoo_javbus").click(
function () {
rename(renameAvmooJavbus, "avmoo", "video", true);
});
$("a#rename_video_javbus_detail").click(
function () {
rename(renameJavbusDetail, "javbus", "video", true);
});
$("a#video_part_format").click(
function () {
videoPartFormat();
});
$("a#rename_picture_avmoo").click(
function () {
rename(renameAvmoo, "avmoo", "picture", true);
});
$("a#rename_picture_javbus").click(
function () {
rename(renameJavbus, "javbus", "picture", true);
});
$("a#rename_picture_FC2").click(
function () {
rename(renameFc2, "fc2", "picture", true);
});
$("a#rename_picture_mgstage").click(
function () {
rename(renameMgstage, "mgstage", "picture", true);
});
console.log("添加按钮");
// 结束定时任务
clearInterval(interval);
}
}
/**
* 执行改名方法
* @param call 回调函数
* @param site 网站
* @param rntype 改名类型 video picture
* @param ifAddDate 是否添加时间
*/
function rename(call, site, rntype, ifAddDate ) {
// 获取所有已选择的文件
let list = $("iframe[rel='wangpan']")
.contents()
.find("li.selected")
.each(function (index, v) {
let $item = $(v);
// 原文件名称
let file_name = $item.attr("title");
// 文件类型
let file_type = $item.attr("file_type");
// 文件id
let fid;
// 后缀名
let suffix;
if (file_type === "0") {
// 文件夹
fid = $item.attr("cate_id");
} else {
// 文件
fid = $item.attr("file_id");
// 处理后缀
let lastIndexOf = file_name.lastIndexOf('.');
if (lastIndexOf !== -1) {
suffix = file_name.substring(lastIndexOf, file_name.length);
file_name = file_name.substring(0, lastIndexOf);
}
}
if (fid && file_name) {
let VideoCode;
// 正则匹配番号
if (site == "mgstage"){
VideoCode = getVideoCode(file_name,"mgstage");
}else if (site == "fc2"){
VideoCode = getVideoCode(file_name,"fc2");
}else{
VideoCode = getVideoCode(file_name);
}
console.log("正则匹配番号:" + VideoCode.fh);
if (VideoCode.fh) {
if ( rntype=="video" ){
// 校验是否是中文字幕
let ifChineseCaptions = checkifChineseCaptions(VideoCode.fh, file_name);
// 执行查询
console.log("开始查询");
call(fid, rntype, VideoCode.fh, suffix, VideoCode.if4k, ifChineseCaptions, VideoCode.part, ifAddDate);
} else if ( rntype=="picture" ){
// 是图片时,向part传图片名冗余,不要中字判断,只在页面获取编号
// 图片名冗余
let picCaptions = getPicCaptions(VideoCode.fh, file_name);
let ifChineseCaptions;
// 执行查询
console.log("开始查询");
call(fid, rntype, VideoCode.fh, suffix, VideoCode.if4k, ifChineseCaptions, picCaptions, ifAddDate);
}
}
}
});
// if(!Main.ReInstance({type:'', star:'', is_q: '', is_share:''})){window.location.reload();}
// if(list){window.location.reload();}
}
/**
* 通过avmoo搜索+javbus详情页进行查询
* @param fid 文件id
* @param rntype 改名类型 video picture
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param part 视频分段,图片冗余文件名
* @param ifAddDate 是否添加时间
* @param searchUrl 请求地址
*/
function renameAvmooJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestAvmooJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, avmooSearch);
}
function requestAvmooJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
let title;
let fh_o; //网页上的番号
let date;
let moviePage;
let actors = [];
let url_s = searchUrl + fh;
let getAvmooSearch = new Promise((resolve, reject) => {
console.log("处理搜索页 " + url_s);
GM_xmlhttpRequest({
method: "GET",
url: url_s,
onload: xhr => {
let response = $(xhr.responseText);
if (!(response.find("div.alert").length)) {
/*
// 标题
title = response
.find("div.photo-frame img")
.attr("title");
// 时间
date = response
.find("div.photo-info > span")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
*/
// 番号
fh_o = response
.find("div.photo-info date:first")
.html();
// 详情页
moviePage = response
.find("a.movie-box")
.attr("href");
console.log("获取到 " + fh_o );
resolve(moviePage);
}
}
});
});
function getJavbusDetail(){
return new Promise((resolve, reject) => {
if ( rntype=="picture" ){
resolve();
} else if ( rntype=="video" ){
if(moviePage){
moviePage = javbusBase + fh_o;
console.log("处理详情页:" + moviePage);
GM_xmlhttpRequest({
method: "GET",
url: moviePage,
onload: xhr => {
let response = $(xhr.responseText);
// 标题
title = response
.find("h3")
.html();
title = title.slice(fh_o.length+1);
// 时间
date = response
.find("p:nth-of-type(2)")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
// 演员们
let actorTags = response.find("div.star-name").each(function(){
actors.push($(this).find("a").attr("title"));
});
console.log('演员 '+actors);
/*
for ( let actor of actorTags) {
actors.push(actor.find("a").attr("title"));
}
*/
resolve();
}
});
}else{
resolve();
}
}
});
}
function setName(){
return new Promise((resolve, reject) => {
if(moviePage){
let actor = actors.toString();
console.log(actor);
// 构建新名称
let newName = buildNewName(fh_o, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actor, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh_o);
console.log("新名: "+newName);
}
resolve(newName);
}else if (searchUrl !== javbusUncensoredSearch) {
console.log("查询无码 " + searchUrl);
// 进行无码重查询
requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, javbusUncensoredSearch);
}else {
resolve("没有查到结果");
}
});
}
getAvmooSearch.then(getJavbusDetail)
.then(setName,setName)
.then(function(result){
console.log("改名结束," + result);
});
}
/**
* 通过javbus详情页进行查询
* 请求javbus,并请求115进行改名
* @param fid 文件id
* @param rntype 改名类型 video picture
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param part 视频分段,图片冗余文件名
* @param ifAddDate 是否添加时间
* @param searchUrl 请求地址
*/
function renameJavbusDetail(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestJavbusDetail(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, javbusSearch);
}
function requestJavbusDetail(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
let title;
let date;
let moviePage = javbusBase + fh;
let actors = [];
// 获取javbus详情页内信息
let getJavbusDetail = new Promise((resolve, reject) => {
console.log("处理详情页:" + moviePage);
if(moviePage){
GM_xmlhttpRequest({
method: "GET",
url: moviePage,
onload: xhr => {
let response = $(xhr.responseText);
// 标题
title = response
.find("h3")
.html();
title = title.slice(fh.length+1);
// 时间
date = response
.find("p:nth-of-type(2)")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
// 演员们
let actorTags = response.find("div.star-name").each(function(){
actors.push($(this).find("a").attr("title"));
});
console.log('演员:'+actors);
resolve();
}
});
}else{
resolve();
}
});
function setName(){
return new Promise((resolve, reject) => {
if(moviePage){
let actor = actors.toString();
// 构建新名称
let newName = buildNewName(fh, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actor, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh);
console.log("新名: "+newName);
}
resolve(newName);
}else if (searchUrl !== javbusUncensoredSearch) {
console.log("查询无码 " + searchUrl);
// 进行无码重查询
requestJavbus(fid, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, javbusUncensoredSearch);
}else {
resolve("没有查到结果");
}
});
}
getJavbusDetail.then(setName,setName)
.then(function(result){
console.log("改名结束," + result);
});
}
/**
* 通过javbus进行查询
* 请求javbus,并请求115进行改名
* @param fid 文件id
* @param rntype 改名类型 video picture
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param part 视频分段,图片冗余文件名
* @param ifAddDate 是否添加时间
* @param searchUrl 请求地址
*/
function renameJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, javbusSearch);
}
function requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
let title;
let fh_o; //网页上的番号
let date;
let moviePage;
let actors = [];
let url_s = searchUrl + fh;
let getJavbusSearch = new Promise((resolve, reject) => {
console.log("处理搜索页:" + url_s);
GM_xmlhttpRequest({
method: "GET",
url: url_s,
onload: xhr => {
let response = $(xhr.responseText);
/*
// 标题
title = response
.find("div.photo-frame img")
.attr("title");
// 时间
date = response
.find("div.photo-info > span")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
*/
// 番号
fh_o = response
.find("div.photo-info date:first")
.html();
// 详情页
moviePage = response
.find("a.movie-box")
.attr("href");
console.log("获取到 " + fh_o );
resolve(moviePage);
}
});
});
function getJavbusDetail(){
return new Promise((resolve, reject) => {
if ( rntype=="picture" ){
console.log("跳过详情页");
resolve();
} else if ( rntype=="video" ){
if(moviePage){
console.log("处理详情页:" + moviePage);
GM_xmlhttpRequest({
method: "GET",
url: moviePage,
onload: xhr => {
let response = $(xhr.responseText);
// 标题
title = response
.find("h3")
.html();
title = title.slice(fh.length+1);
// 时间
date = response
.find("p:nth-of-type(2)")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
// 演员们
let actorTags = response.find("div.star-name").each(function(){
actors.push($(this).find("a").attr("title"));
});
console.log('演员 '+actors);
/*
for ( let actor of actorTags) {
actors.push(actor.find("a").attr("title"));
}
*/
resolve();
}
});
}else{
resolve();
}
}
});
}
function setName(){
return new Promise((resolve, reject) => {
if(moviePage){
let actor = actors.toString();
console.log(actor);
// 构建新名称
let newName = buildNewName(fh_o, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actor, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh_o);
console.log("新名: "+newName);
}
resolve(newName);
}else if (searchUrl !== javbusUncensoredSearch) {
console.log("查询无码 " + searchUrl);
// 进行无码重查询
requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, javbusUncensoredSearch);
}else {
resolve("没有查到结果");
}
});
}
getJavbusSearch.then(getJavbusDetail)
.then(setName,setName)
.then(function(result){
console.log("改名结束," + result);
});
}
/**
* 通过avmoo进行查询
* 请求avmoo,并请求115进行改名
* @param fid 文件id
* @param rntype 改名类型 video picture
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param part 视频分段,图片冗余文件名
* @param ifAddDate 是否添加时间
* @param searchUrl 请求地址
*/
function renameAvmoo(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestAvmoo(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, avmooSearch);
}
function requestAvmoo(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
let title;
let fh_o; //网页上的番号
let date;
let moviePage;
let actors = [];
let url_s = searchUrl + fh;
let getAvmooSearch = new Promise((resolve, reject) => {
console.log("处理搜索页 " + url_s);
GM_xmlhttpRequest({
method: "GET",
url: url_s,
onload: xhr => {
let response = $(xhr.responseText);
if (!(response.find("div.alert").length)) {
/*
// 标题
title = response
.find("div.photo-frame img")
.attr("title");
// 时间
date = response
.find("div.photo-info > span")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
*/
// 番号
fh_o = response
.find("div.photo-info date:first")
.html();
// 详情页
moviePage = response
.find("a.movie-box")
.attr("href");
console.log("获取到 " + fh_o );
resolve(moviePage);
}
}
});
});
function getAvmooDetail(){
return new Promise((resolve, reject) => {
if ( rntype=="picture" ){
console.log("跳过详情页");
resolve();
} else if ( rntype=="video" ){
if(moviePage){
console.log("处理影片页 " + moviePage);
GM_xmlhttpRequest({
method: "GET",
url: moviePage,
onload: xhr => {
let response = $(xhr.responseText);
// 标题
title = response
.find("h3")
.html();
title = title.slice(fh.length+1);
// 时间
date = response
.find("p:nth-of-type(2)")
.html();
date = date.match(/\d{4}\-\d{2}\-\d{2}/);
// 演员们
let actorTags = response.find("a.avatar-box").each(function(){
actors.push($(this).find("span").html());
});
console.log('演员 '+actors);
resolve();
},
});
}else{
resolve();
}
}
});
}
function setName(){
return new Promise((resolve, reject) => {
if(moviePage){
let actor = actors.toString();
console.log(actor);
// 构建新名称
let newName = buildNewName(fh_o, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actor, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh_o);
console.log("新名: "+newName);
}
resolve(newName);
} else if (searchUrl !== avmooUncensoredSearch) {
// 进行无码重查询
requestAvmoo(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, avmooUncensoredSearch);
}else {
resolve("没有查到结果");
}
});
}
getAvmooSearch.then(getAvmooDetail)
.then(setName,setName)
.then(function(result){
console.log("改名结束," + result);
});
}
/**
* 通过FC2进行查询
* 请求FC2,并请求115进行改名
* @param fid 文件id
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param ifAddDate 是否带时间
* @param searchUrl 请求地址*
*/
function renameFc2(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestFC2(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, Fc2Search);
}
function requestFC2(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
GM_xmlhttpRequest({
method: "GET",
url: searchUrl + fh +"/",
onload: xhr => {
console.log("处理影片页 " + searchUrl + fh +"/");
// 匹配标题
let response = $(xhr.responseText);
let title = response
.find("div.items_article_MainitemThumb img")
.attr("title");
console.log("获取到标题 " + title );
// 卖家
let user = response
.find("div.items_article_headerInfo > ul > li a:last ")
.html();
// 上架时间 上架时间 : 2020/06/17
let date = response
.find("div.items_article_Releasedate p")
.html();
date = date.replace(/\s+/g,"").replace(/:/g, "").replace(/\//g, "-");
if ( rntype=="picture" ){
if ( fh && title ) {
title="";
user="";
date="";
}
}
fh = "FC2-PPV-" + fh;
if (title) {
// 构建新名称
let newName = buildNewName(fh, rntype, suffix, if4k, ifChineseCaptions, part, title, date, user, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh);
}
} else if (searchUrl !== javbusUncensoredSearch) {
GM_notification(getDetails(fh, "商品页可能已消失"));
// 进行无码重查询
// requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, javbusUncensoredSearch);
}
}
})
}
/**
* 通过mgstage进行查询
* 请求mgstage,并请求115进行改名
* @param fid 文件id
* @param fh 番号
* @param suffix 后缀
* @param ifChineseCaptions 是否有中文字幕
* @param part 是图片时,向part传图片名冗余
* @param ifAddDate 是否带时间
* @param searchUrl 请求地址
*/
function renameMgstage(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate) {
requestmgstage(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, mgstageSearch);
}
function requestmgstage(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, ifAddDate, searchUrl) {
GM_xmlhttpRequest({
method: "GET",
url: searchUrl + fh +"/",
onload: xhr => {
console.log("处理影片页 " + searchUrl + fh +"/");
// 匹配标题
let response = $(xhr.responseText);
let title = response
.find("div.common_detail_cover > h1")
.html()
.trim();
console.log("获取到标题 " + title );
// 出演
let actor = response
.find("div.detail_data > table:last > tbody > tr:first > td")
.html();
let actors = [];
// 判断<a>
if (actor.toString().match(/<.*>/)) {
let actorTags = response.find("div.detail_data > table:last > tbody > tr:first > td > a").each(function(){
actors.push($(this).html().trim());
});
actors = actors.toString();
}else{
actors = actor.trim();
}
// 品番: 200GANA-2295
// 因界面多语言问题,无法获取
// 配信開始日: 2020/06/23
let date = response
.find("div.detail_data > table:last > tbody > tr:eq(4) > td")
.html()
.trim();
date = date.replace(/\s+/g,"").replace(/:/g, "").replace(/\//g, "-").trim();
if ( rntype=="picture" ){
if ( fh && title ) {
title="";
actors="";
date="";
}
}
if (title) {
// 构建新名称
let newName = buildNewName(fh, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actors, ifAddDate);
if (newName) {
// 修改名称
send_115(fid, newName, fh);
}
} else if (searchUrl !== javbusUncensoredSearch) {
GM_notification(getDetails(fh, "商品页可能已消失"));
// 进行无码重查询
// requestJavbus(fid, rntype, fh, suffix, if4k, ifChineseCaptions, part, javbusUncensoredSearch);
}
}
})
}
/**
* 图片名冗余
* @param fh 番号
* @param title 标题
*/
function getPicCaptions(fh, title) {
let regExp = new RegExp(fh + "[_-]?[A-Z]{1,5}");
let match = title.toUpperCase().match(regExp);
if (match) {
let houzhui = title.slice( fh.length , title.length )
console.log("找到后缀" + houzhui);
return houzhui;
}
}
/**
* 校验是否为中文字幕
* @param fh 番号
* @param title 标题
*/
function checkifChineseCaptions(fh, title) {
if (title.indexOf("中文字幕") !== -1) {
return true;
}
if (title.indexOf("中字") !== -1) {
return true;
}
let regExp = new RegExp("[_-]?C(?!D)");
let match = title.toUpperCase().match(regExp);
if (match) {
return true;
}
}
/**
* 构建新名称:番号 中文字幕 日期 标题 文件名不超过255
* @param fh 番号
* @param rntype 改名类型 video picture
* @param suffix 后缀,扩展名
* @param ifChineseCaptions 是否有中文字幕
* @param part 视频分段,图片冗余文件名
* @param title 番号标题
* @param date 日期
* @param actor 演员
* @param ifAddDate 是否加日期
* @returns {string} 新名称
*/
function buildNewName(fh, rntype, suffix, if4k, ifChineseCaptions, part, title, date, actor, ifAddDate) {
if ( rntype=="video" ){
if (title) {
let newName = String(fh);
// 是4k
if (if4k) {
newName = newName + if4k;
}
// 有中文字幕
if (ifChineseCaptions) {
newName = newName + "-C";
}
if (part){
newName = newName + "_P" + part;
}
// 有演员
if (actor) {
newName = newName + " " + actor;
}
// 拼接标题 判断长度
newName = newName + " " + title;
if ( newName.length > 200 ){
newName = newName.substring(0, 200);
newName += "...";
}
// 有时间
if (ifAddDate && date) {
newName = newName + " " + date;
}
if (suffix) {
// 文件保存后缀名
newName = newName + suffix;
}
return newName;
}
} else if ( rntype=="picture" ){
if (fh){
let newName = String(fh);
if (part){
newName = newName + part;
}
if (suffix) {
// 文件保存后缀名
newName = newName + suffix;
}
return newName;
}
}
}
/**
* 115名称不接受(\/:*?\"<>|)
* @param name
*/
function stringStandard(name) {
return name.replace(/\\/g, "")
.replace(/\//g, " ")
.replace(/:/g, " ")
.replace(/\?/g, " ")
.replace(/"/g, " ")
.replace(/</g, " ")
.replace(/>/g, " ")
.replace(/\|/g, "")
.replace(/\*/g, " ");
}
/**
* 请求115接口改名
* @param id 文件id
* @param name 要修改的名称
* @param fh 番号
*/
function send_115(id, name, fh) {
let file_name = stringStandard(name);
$.post("https://webapi.115.com/files/edit", {
fid: id,
file_name: file_name
},
function (data, status) {
let result = JSON.parse(data);
if (!result.state) {
GM_notification(getDetails(fh, "修改失败"));
console.log("请求115接口异常: " + unescape(result.error
.replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1')));
} else {
GM_notification(getDetails(fh, "修改成功"));
console.log("修改文件名称,fh:" + fh, "name:" + file_name);
}
}
);
}
/**
* 通知参数
* @param text 内容
* @param title 标题
* @returns {{text: *, title: *, timeout: number}}
*/
function getDetails(text, title) {
return {
text: text,
title: title,
timeout: 1000
};
}
/**
* 获取番号
* @param title 源标题
* @param type 番号类型 mgstage fc2
* @returns {string} 提取的番号
*/
function getVideoCode(title, type="nomal") {
title = title.toUpperCase();
console.log("传入title: " + title);
// 判断是否多集
let part; //FHD1 hhb1
if (!part) {
part = title.match(/CD\d{1,2}/);
}if (!part) {
part = title.match(/HD\d{1,2}/);
}if (!part) {
part = title.match(/FHD\d{1,2}/);
}if (!part) {
part = title.match(/HHB\d{1,2}/);
}
if (part){
part = part.toString().match(/\d+/).toString();
console.log("识别多集:" + part);
}
let if4k;
if (!if4k) {
if4k = title.match(/(-4K){1}/);
if(if4k){ if4k = "-4k";}
} if (!if4k) {
if4k = title.match(/(VP9版){1}/);
if(if4k){ if4k = "-4kVP9版";}
} if (!if4k) {
if4k = title.match(/(H264版){1}/);
if(if4k){ if4k = "-4kH264版";}
}
title = title.replace("SIS001", "")
.replace("1080P", "")
.replace("720P", "")
.replace("[JAV] [UNCENSORED]","")
.replace("[THZU.CC]","")
.replace("[22SHT.ME]","")
.replace("[7SHT.ME]","")
.replace("BIG2048.COM","")
.replace("FUN2048.COM@","")
.replace("HHD800.COM@","")
.replace(".HHB","分段")
.replace(".FHD","分段")
.replace(".HD","分段");
console.log("修正后的title: " + title);
let t = '';
if (type=="mgstage"){
console.log("分析mgstage编号");
t = title.match(/\d{3,4}[A-Z]{3,4}[\-_]?\d{3,4}/)
if (!t) { // シロウトTV @SIRO-3585
t = title.match(/[A-Z]{2,5}[\-_]{1}\d{3,5}/);
}
}else if (type=="fc2"){
console.log("分析fc2编号");
t = title.match(/(FC2){0,1}[\-_ ]{0,1}(PPV){0,1}[\-_ ]{0,1}(\d{5,8})/);
if(t){
console.log("找到番号:" + t[0]);
console.log("查找番号:" + t[3]);
t = t[1];
}
}else {
t = title.match(/T28[\-_]\d{3,4}/);
// 一本道
if (!t) {
t = title.match(/1PONDO[\-_ ]\d{6}[\-_]\d{2,4}/);
if (t) {