forked from manhere/BiliPlus-lcz970
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo.php
executable file
·1439 lines (1439 loc) · 78.8 KB
/
do.php
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
<?php
/* Require Config Files */
require dirname(dirname(__FILE__)).'/task/config.php';
require dirname(dirname(__FILE__)).'/task/mysql.php';
/* XML To Array Function For Parsing Bilibili Interface XML Doc */
class XML2Array {
private static $xml = null;
private static $encoding = 'UTF-8';
/**
* Initialize the root XML node [optional]
* @param $version
* @param $encoding
* @param $format_output
*/
public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) {
self::$xml = new DOMDocument($version, $encoding);
self::$xml->formatOutput = $format_output;
self::$encoding = $encoding;
}
/**
* Convert an XML to Array
* @param string $node_name - name of the root node to be converted
* @param array $arr - aray to be converterd
* @return DOMDocument
*/
public static function &createArray($input_xml) {
$xml = self::getXMLRoot();
if(is_string($input_xml)) {
$parsed = $xml->loadXML($input_xml);
if(!$parsed) {
throw new Exception('[XML2Array] Error parsing the XML string.');
}
} else {
if(get_class($input_xml) != 'DOMDocument') {
throw new Exception('[XML2Array] The input XML object should be of type: DOMDocument.');
}
$xml = self::$xml = $input_xml;
}
$array[$xml->documentElement->tagName] = self::convert($xml->documentElement);
self::$xml = null; // clear the xml node in the class for 2nd time use.
return $array;
}
/**
* Convert an Array to XML
* @param mixed $node - XML as a string or as an object of DOMDocument
* @return mixed
*/
private static function &convert($node) {
$output = array();
switch ($node->nodeType) {
case XML_CDATA_SECTION_NODE:
// we do not need cdata nodes, so we disabled it
//$output['@cdata'] = trim($node->textContent);
$output = trim($node->textContent);
break;
case XML_TEXT_NODE:
$output = trim($node->textContent);
break;
case XML_ELEMENT_NODE:
// for each child node, call the covert function recursively
for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) {
$child = $node->childNodes->item($i);
$v = self::convert($child);
if(isset($child->tagName)) {
$t = $child->tagName;
// assume more nodes of same kind are coming
if(!isset($output[$t])) {
$output[$t] = array();
}
$output[$t][] = $v;
} else {
//check if it is not an empty text node
if($v !== '') {
$output = $v;
}
}
}
if(is_array($output)) {
// if only one node of its kind, assign it directly instead if array($value);
foreach ($output as $t => $v) {
if(is_array($v) && count($v)==1) {
$output[$t] = $v[0];
}
}
if(empty($output)) {
//for empty nodes
$output = '';
}
}
// loop through the attributes and collect them
if($node->attributes->length) {
$a = array();
foreach($node->attributes as $attrName => $attrNode) {
$a[$attrName] = (string) $attrNode->value;
}
// if its an leaf node, store the value in @value instead of directly storing it.
if(!is_array($output)) {
$output = array('@value' => $output);
}
$output['@attributes'] = $a;
}
break;
}
return $output;
}
/*
* Get the root XML node, if there isn't one, create it.
*/
private static function getXMLRoot(){
if(empty(self::$xml)) {
self::init();
}
return self::$xml;
}
}
/* Sign Generate Function For Bilibili API Interface */
function get_sign($params, $key)
{
$_data = array();
ksort($params);
reset($params);
foreach ($params as $k => $v)
{
$_data[] = $k . '=' . rawurlencode($v);
}
$_sign = implode('&', $_data);
return strtolower(md5($_sign.$key));
}
/* Core Function For Fetching Data From Bilibili */
function UpdateCache($av,$page,$appkey,$appsecret)
{
global $update;
global $title;
global $apijson;
global $mp4json;
global $mp3file;
global $cid;
global $videoxml;
global $error;
global $e_text;
$update = 1;
if (empty($_COOKIE["access_key"]))
{
$error = 1;
$e_text = '<div class="framesubtitle">无哔哩哔哩账户信息</div><div class="errordescription"><b>服务器需要连接哔哩哔哩账户后获取信息。</b><br/>请点击页面右上方的“连接哔哩哔哩账户”登录哔哩哔哩后访问此页面。</div>Error: [-403] No Access_Key, please login.';
}
else
{
$timestamp = time();
$headers['CLIENT-IP'] = '218.22.21.21';
$headers['X-FORWARDED-FOR'] = '218.22.21.21';
$headers['Accept-Encoding'] = 'gzip,deflate,sdcl';
$headers['User-Agent'] = 'BiliPlus/2.0.0 ([email protected])';
$headers['Referer'] = 'http://www.bilibili.com/video/av'.$av;
$headerArr = array();
foreach($headers as $n=>$v){$headerArr[] = $n.':'.$v;}
$sign = get_sign(array("type"=>"json","appkey"=>$appkey,"id"=>$av,"page"=>$page,"batch"=>"1","check_area"=>"1","ts"=>$timestamp,"platform"=>$platform,"access_key"=>$_COOKIE["access_key"]),$appsecret);
$apiurl = 'http://api.bilibili.com/view?type=json&appkey='.$appkey.'&id='.$av.'&page='.$page.'&batch=1&check_area=1&ts='.$timestamp.'&platform='.$platform.'&access_key='.$_COOKIE["access_key"].'&sign='.$sign;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$apiurl);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArr);
curl_setopt($curl, CURLOPT_HEADER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,1);
$apijson = curl_exec($curl);
curl_close($curl);
$info = json_decode($apijson,true);
if (!array_key_exists("code",$info))
{
if (isset($info['list'][($page-1)]['cid']))
{
$videotitle = $info['title'];
$cid = $info['list'][($page-1)]['cid'];
//MP3 MUSIC FETCH//
$mp3file = '';
//MP3 MUSIC FETCH//
//MP4 VIDEO FETCH//
$mp4url = 'http://www.bilibili.com/m/html5?aid='.$av.'&page='.$page;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$mp4url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArr);
curl_setopt($curl, CURLOPT_HEADER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,1);
$mp4html5data = curl_exec($curl);
$mp4html5 = json_decode($mp4html5data,true);
if (!stristr($mp4html5['src'],'error.mp4'))
{
if (stristr($mp4html5['src'],'g3.letv.cn'))
{
$mp4json = json_encode(array('from'=>'letv_high','quality'=>'Original','src'=>$mp4html5['src']));
}
if (stristr($mp4html5['src'],'acgvideo.com'))
{
$mp4json = json_encode(array('from'=>'bilibili_auto','quality'=>'Auto','src'=>$mp4html5['src']));
}
}
else
{
$sign = get_sign(array("otype"=>"json","type"=>"mp4","ts"=>$timestamp,"platform"=>$platform,"quality"=>"2","appkey"=>$appkey,"cid"=>$cid,"access_key"=>$_COOKIE["access_key"]),$appsecret);
$mp4interfaceurl = 'http://interface.bilibili.com/playurl?otype=json&type=mp4&ts='.$timestamp.'&platform='.$platform.'&quality=2&appkey='.$appkey.'&cid='.$cid.'&access_key='.$_COOKIE["access_key"].'&sign='.$sign;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$mp4interfaceurl);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArr);
curl_setopt($curl, CURLOPT_HEADER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,1);
$mp4interfacedata = curl_exec($curl);
$mp4interface = json_decode($mp4interfacedata,true);
if (isset($mp4interface['format']))
{
if (stristr($mp4interface['accept_format'],'hd'))
{
$mp4json = json_encode(array('from'=>'bilibili_high','quality'=>'High','src'=>$mp4interface['durl']{0}['url']));
}
else
{
if (isset($mp4interface['from']))
{
$mp4json = json_encode(array('from'=>$mp4interface['from'],'quality'=>'Auto','src'=>$mp4interface['durl']{0}['url']));
}
else
{
if (stristr($mp4interface['durl']{0}['url'],'g3.letv.cn'))
{
$mp4json = json_encode(array('from'=>'letv_auto','quality'=>'Auto','src'=>$mp4interface['durl']{0}['url']));
}
else
{
$mp4json = json_encode(array('from'=>'sina_low','quality'=>'Low','src'=>$mp4interface['durl']{0}['url']));
}
}
}
}
else
{
if (isset($mp4interface['from']))
{
$mp4json = json_encode(array('from'=>$mp4interface['from'],'quality'=>'Auto','src'=>$mp4interface['durl']{0}['url']));
}
else
{
if (stristr($mp4interface['durl']{0}['url'],'g3.letv.cn'))
{
$mp4json = json_encode(array('from'=>'letv_auto','quality'=>'Auto','src'=>$mp4interface['durl']{0}['url']));
}
else
{
$mp4json = json_encode(array('from'=>'sina_low','quality'=>'Low','src'=>$mp4interface['durl']{0}['url']));
}
}
}
}
curl_close($curl);
//MP4 VIDEO FETCH//
//SOURCE VIDEO FETCH//
$sign = get_sign(array("otype"=>"xml","type"=>"flv","ts"=>$timestamp,"platform"=>$platform,"quality"=>"3","appkey"=>$appkey,"cid"=>$cid,"access_key"=>$_COOKIE["access_key"]),$appsecret);
$interfaceurl = 'http://interface.bilibili.com/playurl?otype=xml&type=flv&ts='.$timestamp.'&platform='.$platform.'&quality=3&appkey='.$appkey.'&cid='.$cid.'&access_key='.$_COOKIE["access_key"].'&sign='.$sign;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$interfaceurl);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headerArr);
curl_setopt($curl, CURLOPT_HEADER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,1);
$videoxml = curl_exec($curl);
curl_close($curl);
//SOURCE VIDEO FETCH//
$errorcheck = json_decode($videoxml,true);
if (empty($errorcheck["error_code"]))
{
$play = simplexml_load_string($videoxml,'SimpleXMLElement',LIBXML_NOCDATA);
if (($play->result)=='succ'||($play->result)=='suee')
{
$error = 0;
}
else
{
if ((string)$play->message=='video is encoding.')
{
$error = 1;
$e_text = '<div class="framesubtitle">视频解析错误:API_ERROR</div><div class="errordescription">无法获取视频文件URL。<br/>“视频正在转码中”,哔哩哔哩API服务器如是说道。<br/>此错误与BiliPlus无关,不要问我“为什么主站现在就能看?”,因为我也不知道为什么。<br/>请尝试过一段时间后刷新数据,给您造成的不便请谅解。</div>Error: ['.$play->type.'] '.$play->message;
}
else
{
$error = 3;
$e_text = '<div class="framesubtitle">视频解析错误:BAD_API_XML</div><div class="errordescription">无法获取视频文件URL。<br/>可能原因是视频已被删除(视频内容不和谐/UP主自行删除)或API无法解析该投稿(乐视云、爱奇艺源可能出现该情况),具体原因请查看下方错误代码。</div>Error: ['.$play->type.'] '.$play->message;
}
}
}
else
{
$error = 3;
$e_text = '<div class="framesubtitle">视频解析错误:API_ERROR</div><div class="errordescription">无法获取视频文件URL。<br/>可能原因是视频已被删除(视频内容不和谐/UP主自行删除)或API无法解析该投稿(乐视云、爱奇艺源可能出现该情况),具体原因请查看下方错误代码。</div>Error: ['.$errorcheck["error_code"].'] '.$errorcheck["error_text"];
}
}
else
{
$error = 1;
$e_text = '<div class="framesubtitle">页面不存在</div><div class="errordescription">AV'.$av.' 没有第 '.$page.' 页!<br/>请确认您输入的AV号及分P页码无误。</div>';
}
}
else
{
if ($info["error"]==-403)
{
$error = 2;
$e_text = '<div class="framesubtitle">权限不足</div><div class="errordescription">服务器不允许您访问此投稿。<br/>可能该视频已被删除或该投稿已被屏蔽。<br/>[B站已加强管理力度,请不要尝试解析已被删除的不和谐视频]</div>Error: ['.$info["code"].'] '.$info["error"];
}
else
{
$error = 2;
$e_text = '<div class="framesubtitle">CID解析错误:NO_SUCH_VIDEO</div><div class="errordescription">无法获取视频CID。<br/>可能原因是您输入的AV号不存在或该投稿仅允许会员浏览,具体原因请查看下方错误代码。</div>Error: ['.$info["code"].'] '.$info["error"];
}
}
}
}
if (!empty($_GET["update"])&&($_GET["update"]==1))
{
if (preg_match("/^[1-9][0-9]*$/",$_GET["av"]))
{
if (!empty($_GET["page"]))
{
if (preg_match("/^[1-9][0-9]*$/",$_GET["page"]))
{
$update = 1;
$page = $_GET["page"];
}
else
{
$error = 1;
$e_text = '<div class="framesubtitle">Bad Request</div><div class="errordescription">参数格式错误,页码请输入纯数字。</div>';
}
}
$apijson = '';
$title = 'AV'.$_GET["av"].' - 数据更新';
UpdateCache($_GET["av"],$page,$appkey,$appsecret);
}
else
{
$error = 1;
$e_text = '<div class="framesubtitle">Bad Request</div><div class="errordescription">参数格式错误,AV号请输入纯数字。</div>';
}
}
else
{
$update = 0;
if (!empty($_GET["act"]))
{
if (empty($_GET["av"])||preg_match("/^[1-9][0-9]*$/",$_GET["av"]))
{
if (!empty($_GET["page"]))
{
if (preg_match("/^[1-9][0-9]*$/",$_GET["page"]))
{
$page = $_GET["page"];
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">参数格式错误,页码请输入纯数字。</div>';
}
}
if ($_GET["act"]=='info')
{
$title = 'AV'.$_GET["av"].' - 下载';
if (!empty($_GET["av"]))
{
if (!empty($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
$id = $_GET["av"].'_'.$page;
$apijson = mysql_query("SELECT * FROM CACHE_PAGE WHERE ID='{$id}'");
if (!mysql_num_rows($apijson))
{
UpdateCache($_GET["av"],$page,$appkey,$appsecret);
}
else
{
$apijson = mysql_fetch_array($apijson);
$datatime = $apijson['LASTUPDATE'];
$info = json_decode($apijson['DATA'],true);
if (!array_key_exists("code",$info))
{
if (isset($info['list'][($page-1)]['cid']))
{
$videotitle = $info['title'];
$cid = $info['list'][($page-1)]['cid'];
if (isset($info['list'][($page-1)]['vid']))
{
$vid = $info['list'][($page-1)]['vid'];
}
else
{
$vid = '不可用';
}
$videoxml = mysql_query("SELECT * FROM CACHE_VIDEO WHERE CID='{$cid}'");
$videoxml = mysql_fetch_array($videoxml);
$data = $videoxml['DATA'];
$errorcheck = json_decode($data,true);
if (empty($errorcheck["error_code"]))
{
if (!!simplexml_load_string($data))
{
$play = XML2Array::createArray($data);
$play = $play['video'];
if (($play['result'])=='succ'||($play['result'])=='suee')
{
$p = 0;
$pagelist = '';
while (isset($info['list'][$p]['cid']))
{
$pagelist = $pagelist.'<a href="/api/do.php?act=info&av='.$_GET["av"].'&page='.$info['list'][$p]['page'].'"><div class="listbox">[P'.($p+1).'] '.$info['list'][$p]['part'].'</div></a>';
$p++;
}
if (!isset($play['durl'][0]['url']))
{
$durldata = $play['durl'];
$play['durl'] = '';
$play['durl'][0] = $durldata;
}
$videolengthms = ($play['timelength'])*1.0;
$videolength = str_pad(floor($videolengthms/60000),3,"0", STR_PAD_LEFT).':'.sprintf("%02d",round(fmod(($videolengthms/1000),60),3));
$part = 0;
$video = '';
while(!empty($play['durl'][$part]['url']))
{
$partlengthms = $play['durl'][$part]['length'];
$partlength = str_pad(floor($partlengthms/60000),2,"0", STR_PAD_LEFT).':'.sprintf("%02d",round(fmod(($partlengthms/1000),60),3));
$urlencode1 = $play['durl'][$part]['url'];
$parturl = $urlencode1;
$video = $video.'<a href="'.$parturl.'" target="_blank" title="[分段'.($part+1).'] 时长:'.$partlength.'"><div class="filelist">[分段'.($part+1).'] '.$partlength.'</div></a>';
$part++;
}
$urlencode2 = urlencode($apijson['MP3']);
$audiomp3 = 'https://biliplus.sinaapp.com/url/go.php?url='.$urlencode2;
$getmp4 = json_decode($apijson['MP4'],true);
$urlencode3 = $getmp4['src'];
$videomp4 = $urlencode3;
$pages = $info['pages'];
$from_real = $play['from'];
$from_src = $info['list'][($page-1)]['type'];
if($from_real=='sina') $from_real='新浪视频';
if($from_real=='youku') $from_real='优酷视频';
if($from_real=='tudou') $from_real='土豆视频';
if($from_real=='qq') $from_real='腾讯视频';
if($from_real=='local') $from_real='哔哩哔哩云视频';
if($from_real=='letv') $from_real='乐视云视频';
if($from_real=='mletv') $from_real='乐视版权';
if($from_real=='sohu') $from_real='搜狐版权';
if($from_real=='pptv') $from_real='PPTV版权';
if($from_real=='iqiyi') $from_real='爱奇艺版权';
if($from_real=='vupload') $from_real='哔哩哔哩版权';
if(empty($from_real)) $from_real = '未知';
$src = $play['src'];
if($src>=400) $from_real='新浪视频';
if($from_src=='sina') $from_src='新浪视频';
if($from_src=='youku') $from_src='优酷视频';
if($from_src=='tudou') $from_src='土豆视频';
if($from_src=='qq') $from_src='腾讯视频';
if($from_src=='local') $from_src='哔哩哔哩云视频';
if($from_src=='letv') $from_src='乐视云视频';
if($from_src=='mletv') $from_src='乐视版权';
if($from_src=='sohu') $from_src='搜狐版权';
if($from_src=='pptv') $from_src='PPTV版权';
if($from_src=='iqiyi') $from_src='爱奇艺版权';
if($from_src=='vupload') $from_src='哔哩哔哩版权';
if(empty($from_src)) $from_src = '未知';
$parttitle = $info['list'][($page-1)]['part'];
$author = $info['author'];
$authorid = $info['mid'];
$videoplay = $info['play'];
$videodanmu = $info['video_review'];
$videoscore = $info['credit'];
$videocoin = $info['coins'];
$videofavorite = $info['favorites'];
$videotime = $info['created_at'];
$danmakuxml = 'http://www.bilibilijj.com/ashx/Barrage.ashx?f=true&s=xml&av=&p=&cid='.$cid.'&n='.$videotitle;
$danmakuass = 'http://www.bilibilijj.com/ashx/Barrage.ashx?f=true&s=ass&av=&p=&cid='.$cid.'&n='.$videotitle;
$title = $videotitle.' - AV'.$_GET["av"].' - 下载';
}
else
{
if ((string)$play->message=='video is encoding.')
{
$error = '<div class="framesubtitle">视频解析错误:API_ERROR</div><div class="errordescription">无法获取视频文件URL。<br/>“视频正在转码中”,哔哩哔哩API服务器如是说道。<br/>此错误与BiliPlus无关,不要问我“为什么主站现在就能看?”,因为我也不知道为什么。<br/>请尝试过一段时间后刷新数据,给您造成的不便请谅解。</div>Error: ['.$play->type.'] '.$play->message;
}
else
{
$error = '<div class="framesubtitle">视频解析错误:BAD_API_XML</div><div class="errordescription">无法获取视频文件URL。<br/>可能原因是视频已被删除(视频内容不和谐/UP主自行删除)或API无法解析该投稿(乐视云、爱奇艺源可能出现该情况),具体原因请查看下方错误代码。</div>Error: ['.$play->type.'] '.$play->message;
}
}
}
else
{
$error = '<div class="framesubtitle">视频解析错误:NETWORK_ERROR</div><div class="errordescription">服务器无法获取正确的视频接口数据格式。<br/>可能原因是服务器与哔哩哔哩接口的网络连接不畅或网络不稳定,请尝试刷新数据,具体原因请查看下方错误代码。</div>Error: [-400] bad xml document';
}
}
else
{
$error = '<div class="framesubtitle">视频解析错误:API_ERROR</div><div class="errordescription">无法获取视频文件URL。<br/>可能原因是视频已被删除(视频内容不和谐/UP主自行删除)或API无法解析该投稿(乐视云、爱奇艺源可能出现该情况),具体原因请查看下方错误代码。</div>Error: ['.$errorcheck["error_code"].'] '.$errorcheck["error_text"];
}
}
else
{
$error = 'AV'.$_GET["av"].' 没有第 '.$_GET["page"].' 页!<br/>AV'.$_GET["av"].' does not have page '.$_GET["page"].' !';
}
}
else
{
if ($info["code"]==-403)
$error = '<div class="framesubtitle">权限不足</div><div class="errordescription">服务器不允许您访问此投稿。<br/>可能该视频已被删除或该投稿已被屏蔽。<br/>[B站已加强管理力度,请不要尝试解析已被删除的不和谐视频]</div>Error: ['.$info["code"].'] '.$info["error"];
else
$error = '<div class="framesubtitle">CID解析错误:NO_SUCH_VIDEO</div><div class="errordescription">无法获取视频CID。<br/>可能原因是您输入的AV号不存在或该投稿仅允许会员浏览,具体原因请查看下方错误代码。</div>Error: ['.$info["code"].'] '.$info["error"];
}
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
if ($_GET["act"]=='play')
{
$title = 'AV'.$_GET["av"].' - 播放';
if ((!empty($_GET["av"]))&&(!empty($_GET["player"])))
{
if (!empty($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
$id = $_GET["av"].'_'.$page;
$apijson = mysql_query("SELECT * FROM CACHE_PAGE WHERE ID='{$id}'");
if (!mysql_num_rows($apijson))
{
UpdateCache($_GET["av"],$page,$appkey,$appsecret);
}
else
{
$apijson = mysql_fetch_array($apijson);
$datatime = $apijson['LASTUPDATE'];
$return = json_decode($apijson['DATA'],true);
if (!array_key_exists("error",$return))
{
$videotitle = $return['title'];
if (isset($return['list'][($page-1)]['cid']))
{
$cid = $return['list'][($page-1)]['cid'];
$p = 0;
$pagelist = '';
while (isset($return['list'][$p]['cid']))
{
$pagelist = $pagelist.'<a href="/api/do.php?act=play&av='.$_GET["av"].'&page='.$return['list'][$p]['page'].'&player='.$_GET["player"].'"><div class="listbox">[P'.($p+1).'] '.$return['list'][$p]['part'].'</div></a>';
$p++;
}
if ($_GET["player"]=='mukio')
{
$mp4 = json_decode($apijson['MP4'],true);
$mp4video = urlencode($mp4['src']);
/* MukioPlayer has been canceled in my plan, you can use another player here instead. */
$divplay = '<b>由于近期各大视频网站升级视频解析算法,我们暂时无法获取视频文件地址,因此暂停提供MukioPlayer播放服务,请等待恢复,抱歉</b><br/>PS:下载功能和其他播放器不受影响';
//$divplay = '<iframe height="720" width="1280" src="/play/do.php?player=mukio&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='bilibili')
{
$divplay = '<iframe height="650" width="100%" src="/play/do.php?player=bilibili&aid='.$_GET["av"].'&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='bilibili_bili')
{
$divplay = '<iframe height="650" width="100%" src="/play/do.php?player=bilibili_bili&aid='.$_GET["av"].'&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='bilibili_iqiyi720')
{
$divplay = '<iframe height="650" width="100%" src="/play/do.php?player=bilibili_iqiyi720&aid='.$_GET["av"].'&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='bilibili_iqiyi1080')
{
$divplay = '<iframe height="650" width="100%" src="/play/do.php?player=bilibili_iqiyi1080&aid='.$_GET["av"].'&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='bilibili_tucao')
{
$divplay = '<iframe height="650" width="100%" src="/play/do.php?player=bilibili_tucao&aid='.$_GET["av"].'&cid='.$cid.'" scrolling="no" border="0" frameborder="no" framespacing="0"></iframe>';
}
if ($_GET["player"]=='html5')
{
$mp4 = json_decode($apijson['MP4'],true);
$video1 = $mp4['src'];
$api = json_decode(file_get_contents('http://interface.bilibili.com/playurl?otype=json&appkey=5a88bc9210cda8e6&cid='.$cid.'&type=mp4'),true);
$video2 = $api['durl']{0}['url'];
$comment = 'http://comment.bilibili.com/'.$cid.'.xml';
}
if (empty($_GET["player"]))
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
$parttitle = $return['list'][$page-1]['part'];
$author = $return['author'];
$authorid = $return['mid'];
$videoplay = $return['play'];
$videodanmu = $return['video_review'];
$videoscore = $return['credit'];
$videocoin = $return['coins'];
$videofavorite = $return['favorites'];
$videodescription = $return['description'];
$videopic = $return['pic'];
$videotime = $return['created_at'];
$typeid = $return['tid'];
$title = $videotitle.' - AV'.$_GET["av"].' - 播放';
}
else
{
$error = 'AV'.$_GET["av"].' 没有第 '.$_GET["page"].' 页!<br/>AV'.$_GET["av"].' does not have page '.$_GET["page"].' !';
}
}
else
{
if ($return["code"]==-403)
$error = '<div class="framesubtitle">权限不足</div><div class="errordescription">此页面仅限正式会员浏览。<br/>请点击页面右上方的“连接哔哩哔哩账户”登录哔哩哔哩后访问此页面。</div>Error: ['.$return["code"].'] '.$return["error"];
else
$error = '<div class="framesubtitle">CID解析错误:NO_SUCH_VIDEO</div><div class="errordescription">无法获取视频CID。<br/>可能原因是您输入的AV号不存在或该投稿仅允许会员浏览,具体原因请查看下方错误代码。</div>Error: ['.$return["code"].'] '.$return["error"];
}
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
if ($_GET["act"]=='search')
{
if (empty($_COOKIE["access_key"]))
{
$title = $_GET["word"].' - 搜索';
if (!empty($_GET["word"]))
{
$url = 'http://api.bilibili.com/search?type=json&appkey=5a88bc9210cda8e6&keyword='.$_GET["word"].'&page='.$_GET["p"].'&order='.$_GET["o"].'&pagesize='.$_GET["n"];
$json = file_get_contents($url);
$return = json_decode($json,true);
$property = $return["property"];
$result = $property["result"];
$keyword = $property["QueryKeywords"];
$page = $return["page"];
if ($return["error"]!='overspeed')
{
if ($page!=0)
{
if (!empty($_GET["p"]))
{
$thispage = $_GET["p"];
}
else
{
$thispage = 1;
}
if ($thispage!=1)
{
$prevpage = $thispage-1;
$prevpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$prevpage.'&o='.$_GET["o"].'&n='.$_GET["n"];
}
else
{
$prevpage = '';
$prevpagelink = '';
}
if ($thispage!=$page)
{
$nextpage = $thispage+1;
$nextpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$nextpage.'&o='.$_GET["o"].'&n='.$_GET["n"];
}
else
{
$nextpage = '';
$nextpagelink = '';
}
$firstpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p=1'.'&o='.$_GET["o"].'&n='.$_GET["n"];
$lastpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$page.'&o='.$_GET["o"].'&n='.$_GET["n"];
$nr = 0;
}
else
{
$nr = 1;
}
}
else
{
$error = '<div class="framesubtitle">API错误:OverSpeed</div><div class="errordescription">请求频率过高,服务器拒绝服务。<br/>请稍后重试。</div>';
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
else
{
$title = $_GET["word"].' - 搜索';
if (!empty($_GET["word"]))
{
$sign = get_sign(array("type"=>"json","appkey"=>$appkey,"keyword"=>$_GET["word"],"page"=>$_GET["p"],"order"=>$_GET["o"],"pagesize"=>$_GET["n"],"access_key"=>$_COOKIE["access_key"]),$appsecret);
$json = file_get_contents('http://api.bilibili.com/search?type=json&appkey='.$appkey.'&keyword='.$_GET["word"].'&page='.$_GET["p"].'&order='.$_GET["o"].'&pagesize='.$_GET["n"].'&access_key='.$_COOKIE["access_key"].'&sign='.$sign);
$return = json_decode($json,true);
$property = $return["property"];
$result = $property["result"];
$keyword = $property["QueryKeywords"];
$page = $return["page"];
if ($return["error"]!='overspeed')
{
if ($page!=0)
{
if (!empty($_GET["p"]))
{
$thispage = $_GET["p"];
}
else
{
$thispage = 1;
}
if ($thispage!=1)
{
$prevpage = $thispage-1;
$prevpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$prevpage.'&o='.$_GET["o"].'&n='.$_GET["n"];
}
else
{
$prevpage = '';
$prevpagelink = '';
}
if ($thispage!=$page)
{
$nextpage = $thispage+1;
$nextpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$nextpage.'&o='.$_GET["o"].'&n='.$_GET["n"];
}
else
{
$nextpage = '';
$nextpagelink = '';
}
$firstpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p=1'.'&o='.$_GET["o"].'&n='.$_GET["n"];
$lastpagelink = '/api/do.php?act=search&word='.$_GET["word"].'&p='.$page.'&o='.$_GET["o"].'&n='.$_GET["n"];
$nr = 0;
}
else
{
$nr = 1;
}
}
else
{
$error = '<div class="framesubtitle">API错误:OverSpeed</div><div class="errordescription">请求频率过高,服务器拒绝服务。<br/>请稍后重试。</div>';
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
}
if ($_GET["act"]=='viewsp')
{
if (empty($_COOKIE["access_key"]))
{
$title = $_GET["title"].' - 专题';
if (!empty($_GET["id"]) && !empty($_GET["title"]))
{
if (!empty($_GET["bangumi"]))
$bangumi = $_GET["bangumi"];
else
$bangumi = 0;
$sign = get_sign(array("type"=>"json","appkey"=>$appkey,"spid"=>$_GET["id"],"bangumi"=>$bangumi),$appsecret);
$listurl = file_get_contents('http://api.bilibili.com/spview?type=json&appkey='.$appkey.'&spid='.$_GET["id"].'&bangumi='.$bangumi.'&sign='.$sign);
$list = json_decode($listurl,true);
$result = $list["results"];
$sign = get_sign(array("type"=>"json","appkey"=>$appkey,"spid"=>$_GET["id"]),$appsecret);
$infourl = file_get_contents('http://api.bilibili.com/sp?type=json&appkey='.$appkey.'&spid='.$_GET["id"].'&sign='.$sign);
$info = json_decode($infourl,true);
if ($info["code"]==0)
{
$title = $info["title"].' - 专题';
}
else
{
$error = '<div class="framesubtitle">专题解析错误</div><div class="errordescription">无法获取专题信息。<br/>可能原因是该SPID不存在或该专题仅允许会员浏览,具体原因请查看下方错误代码。</div>Error: ['.$info["code"].'] '.$info["error"];
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
else
{
$title = $_GET["title"].' - 专题';
if (!empty($_GET["id"]) && !empty($_GET["title"]))
{
if (!empty($_GET["bangumi"]))
$bangumi = $_GET["bangumi"];
else
$bangumi = 0;
$sign1 = get_sign(array("type"=>"json","appkey"=>$appkey,"spid"=>$_GET["id"],"bangumi"=>$bangumi,"access_key"=>$_COOKIE["access_key"]),$appsecret);
$list = json_decode(file_get_contents('http://api.bilibili.com/spview?type=json&appkey='.$appkey.'&spid='.$_GET["id"].'&bangumi='.$bangumi.'&access_key='.$_COOKIE["access_key"].'&sign='.$sign1),true);
$result = $list["results"];
$sign2 = get_sign(array("type"=>"json","appkey"=>$appkey,"spid"=>$_GET["id"],"access_key"=>$_COOKIE["access_key"]),$appsecret);
$info = json_decode(file_get_contents('http://api.bilibili.com/sp?type=json&appkey='.$appkey.'&spid='.$_GET["id"].'&access_key='.$_COOKIE["access_key"].'&sign='.$sign2),true);
if ($info["code"]==0)
{
$title = $info["title"].' - 专题';
}
else
{
$error = '<div class="framesubtitle">专题解析错误</div><div class="errordescription">无法获取专题信息。<br/>可能原因是该SPID不存在或该专题仅允许正式会员浏览,具体原因请查看下方错误代码。</div>Error: ['.$info["code"].'] '.$info["error"];
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">服务器无法识别你的请求,请检查你是否填写了所有必须参数…</div>';
}
}
}
if ($_GET["act"]=='logout')
{
$title = '退出登录';
setcookie ("access_key",'',time()-3600,"/");
setcookie ("mid",'',time()-3600,"/");
setcookie ("uname",'',time()-3600,"/");
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">参数格式错误,AV号请输入纯数字。</div>';
}
}
else
{
$error = '<div class="framesubtitle">Bad Request</div><div class="errordescription">参数不足,服务器无法识别你的请求。</div>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="author" content="Tundra" />
<meta name="Copyright" content="Copyright Tundra All Rights Reserved." />
<?php
if (($update==1)&&(($error==0)||($error==2)||($error==3)))
echo '<meta http-equiv="refresh" content="1; url='.str_ireplace('&update=1','',$_SERVER['REQUEST_URI']).'" />';
?>
<meta name="keywords" content="BiliPlus,哔哩哔哩,Bilibili,下载,播放,弹幕,音乐,黑科技,HTML5" />
<meta name="description" content="哔哩哔哩投稿视频、弹幕、音乐下载,更换弹幕播放器,简明现代黑科技 - BiliPlus - ( ゜- ゜)つロ 乾杯~" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title><?php echo $title; ?> - BiliPlus - ( ゜- ゜)つロ 乾杯~</title>
<style type="text/css">
a{text-decoration:none}
#userbar a:link{color:#FFFFFF}
#userbar a:visited{color:#FFFFFF}
#userbar a:hover{color:#CDCDCD}
#userbar a:active{color:#3388FF}
html,body{margin:0px;width:100%;height:100%;font-size:16px;cursor:default}
div.frametitle{font-family:"Microsoft YaHei";font-size:24px;font-weight:bold}
div.framesubtitle{font-family:"Verdana";font-size:16px;font-weight:bold}
div.framedescription{font-family:"Microsoft YaHei";font-size:16px}
div.sidebar{margin:0px;width:150px;height:100%;background-color:#3388FF;box-shadow:5px 0px 0px #858585;position:fixed;top:0px;left:0px}
div.sidebar-title{margin:0px 0px 6px 0px;width:150px;height:75px;background-color:#3388FF;text-align:center;font-family:"Verdana";font-size:50px;font-weight:bold;color:white}
div.sidebar-list{margin:6px 0px 0px 0px;padding:10px 0px 10px 0px;width:150px;text-align:center;font-family:"Microsoft YaHei",SimHei;font-size:20px;font-weight:bold;color:white;box-shadow:0px -6px 0px #FFFFFF}
div.sidebar-about{margin:6px 0px 0px 0px;padding:10px 0px 10px 0px;width:150px;background-color:#3388FF;text-align:center;font-family:"Verdana";font-size:12px;color:white;box-shadow:0px -6px 0px #FFFFFF}
div.sidebar-list-block{margin:0px;padding:10px 0px 10px 0px;width:100%}
div.sidebar div:hover{background:#858585}
div.userbar{margin:0 0 6px 0;padding:0px;width:100%;color:#FFFFFF;text-align:right;font-size:14px;font-family:"Microsoft YaHei";background-color:#D04D74;float:right}
p.userbarcontent{margin:8px}
div.loading{margin:10px 0px 10px 0px;padding:0px;width:100%;height:100%;text-align:center;color:#FFFFFF;font-family:"Microsoft YaHei";font-size:18px;font-weight:bold;background-color:#999999;float:left;display:block;z-index:9}
div.content{margin:0px;padding:0px 0px 0px 160px;width:100%;box-sizing:border-box;float:left;display:block;z-index:1}
input.button{margin:6px 0 6px 0;width:100px;font-family:"Microsoft YaHei";font-size:14px;font-weight:bold}
</style>
</head>
<body onload="LoadContent()">
<div id="userbar" class="userbar">
<?php
if (empty($_COOKIE['login']))
{
echo 'BiliPlus Visitor System</div><script language="javascript" type="text/javascript">window.location.href="/api/login.php?act=reg&url='.urlencode($_SERVER['REQUEST_URI']).'"</script></body></html>';
}
if ($_COOKIE['login']==1)
{
echo '<p class="userbarcontent">欢迎,<b>'.$_COOKIE["uname"].'</b> | <b><a href="'.$loginurl.'">连接哔哩哔哩账户</a></b></p>';
}
if ($_COOKIE['login']==2)
{
echo '<p class="userbarcontent">欢迎,<b>'.$_COOKIE["uname"].'</b><b>(AccessKey:'.$_COOKIE["access_key"].')</b> | <b><a href="/api/login.php?act=logout">退出哔哩哔哩账户</a></b></p>';
}
?>
</div>
<div id="loading" class="loading">
<p>少女祈祷中...<br/>Now Loading...</p>
</div>
<div id="content" class="content">
<?php
if ($update==1)
{
$time = date("Y/m/d H:i:s");
if ($error==1)
{
echo '<style type="text/css">
div.title{font-family:"Microsoft YaHei";font-size:24px;font-weight:bold}
div.subtitle{font-family:"Verdana";font-size:18px;font-weight:bold}
div.boxtitle-1{margin:0px;padding:6px;width:200px;height:28px;color:#FFFFFF;text-align:center;font-family:"Microsoft YaHei";font-size:18px;font-weight:bold;background-color:#006EDC}
div.boxcontent-1{margin:0px;padding:4px 0px 0px 0px;height:150px;border-top:6px solid #1E90FF;clear:both}
div.errordescription{padding:8px;font-family:"Microsoft YaHei";font-size:15px;background-color:#DDDDDD}
div.buttonbackground{padding:12px;text-align:center;background-color:#999999}
</style>
<br/>
<div class="frametitle">糟糕,出错啦!</div><br/><br/>
<div class="boxtitle-1">详细错误信息</div>
<div class="boxcontent-1">'.$e_text.'</div><br/>
<div class="buttonbackground"><input type="button" class="button" value="返回" onclick="history.go(-1)"> <input type="button" class="button" value="帮助" onclick="window.open(\'/?about\')"></div>
';
}
if ($error==2)
{
$id = $_GET["av"].'_'.$page;
$pagedata = mysql_real_escape_string($apijson);
mysql_query("INSERT INTO CACHE_PAGE (ID,SUCCESS,DATA,LASTUPDATE) VALUES ('{$id}','2','{$pagedata}','{$time}') ON DUPLICATE KEY UPDATE SUCCESS=VALUES(SUCCESS),DATA=VALUES(DATA),LASTUPDATE=VALUES(LASTUPDATE)");
echo '<style type="text/css">
div.title{font-family:"Microsoft YaHei";font-size:24px;font-weight:bold}
div.subtitle{font-family:"Verdana";font-size:18px;font-weight:bold}
div.boxtitle-1{margin:0px;padding:6px;width:200px;height:28px;color:#FFFFFF;text-align:center;font-family:"Microsoft YaHei";font-size:18px;font-weight:bold;background-color:#006EDC}
div.boxcontent-1{margin:0px;padding:4px 0px 0px 0px;height:150px;border-top:6px solid #1E90FF;clear:both}
div.errordescription{padding:8px;font-family:"Microsoft YaHei";font-size:15px;background-color:#DDDDDD}
div.buttonbackground{padding:12px;text-align:center;background-color:#999999}
</style>
<br/>
<div class="frametitle">糟糕,出错啦!</div><br/><br/>
<div class="boxtitle-1">详细错误信息</div>
<div class="boxcontent-1">
<div class="errordescription"><b>无法从哔哩哔哩开放平台获取正确数据,正在刷新页面,请稍后...</b></div><br/>
'.$e_text.'
</div><br/>
错误信息已写入缓存数据库...<br/><br/>
<div class="buttonbackground"><input type="button" class="button" value="返回" onclick="history.go(-1)"> <input type="button" class="button" value="帮助" onclick="window.open(\'/?about\')"></div>
';
}
if ($error==3)
{
$id = $_GET["av"].'_'.$page;
$pagedata = mysql_real_escape_string($apijson);
$pagemp4 = mysql_real_escape_string($mp4json);
$videodata = mysql_real_escape_string($videoxml);
mysql_query("INSERT INTO CACHE_PAGE (ID,SUCCESS,DATA,MP3,MP4,LASTUPDATE) VALUES ('{$id}','1','{$pagedata}','{$mp3file}','{$pagemp4}','{$time}') ON DUPLICATE KEY UPDATE SUCCESS=VALUES(SUCCESS),DATA=VALUES(DATA),LASTUPDATE=VALUES(LASTUPDATE)");
mysql_query("INSERT INTO CACHE_VIDEO (CID,SUCCESS,DATA,LASTUPDATE) VALUES ('{$cid}','0','{$videodata}','{$time}') ON DUPLICATE KEY UPDATE SUCCESS=VALUES(SUCCESS),DATA=VALUES(DATA),LASTUPDATE=VALUES(LASTUPDATE)");
echo '<style type="text/css">
div.title{font-family:"Microsoft YaHei";font-size:24px;font-weight:bold}
div.subtitle{font-family:"Verdana";font-size:18px;font-weight:bold}
div.boxtitle-1{margin:0px;padding:6px;width:200px;height:28px;color:#FFFFFF;text-align:center;font-family:"Microsoft YaHei";font-size:18px;font-weight:bold;background-color:#006EDC}
div.boxcontent-1{margin:0px;padding:4px 0px 0px 0px;height:150px;border-top:6px solid #1E90FF;clear:both}
div.errordescription{padding:8px;font-family:"Microsoft YaHei";font-size:15px;background-color:#DDDDDD}
div.buttonbackground{padding:12px;text-align:center;background-color:#999999}
</style>
<br/>
<div class="frametitle">糟糕,出错啦!</div><br/><br/>
<div class="boxtitle-1">详细错误信息</div>
<div class="boxcontent-1">
<div class="errordescription"><b>无法从哔哩哔哩开放平台获取正确数据,正在刷新页面,请稍后...</b></div><br/>
'.$e_text.'
</div><br/>
错误信息已写入缓存数据库...<br/><br/>
<div class="buttonbackground"><input type="button" class="button" value="刷新" onclick="document.location.reload()"> <input type="button" class="button" value="帮助" onclick="window.open(\'/?about\')"></div>
';
}
if ($error==0)
{
$id = $_GET["av"].'_'.$page;
$pagedata = mysql_real_escape_string($apijson);
$pagemp4 = mysql_real_escape_string($mp4json);
$videodata = mysql_real_escape_string($videoxml);
mysql_query("INSERT INTO CACHE_PAGE (ID,SUCCESS,DATA,MP3,MP4,LASTUPDATE) VALUES ('{$id}','1','{$pagedata}','{$mp3file}','{$pagemp4}','{$time}') ON DUPLICATE KEY UPDATE SUCCESS=VALUES(SUCCESS),DATA=VALUES(DATA),MP4=VALUES(MP4),LASTUPDATE=VALUES(LASTUPDATE)");
mysql_query("INSERT INTO CACHE_VIDEO (CID,SUCCESS,DATA,LASTUPDATE) VALUES ('{$cid}','1','{$videodata}','{$time}') ON DUPLICATE KEY UPDATE SUCCESS=VALUES(SUCCESS),DATA=VALUES(DATA),LASTUPDATE=VALUES(LASTUPDATE)");
echo '<style type="text/css">
div.title{font-family:"Microsoft YaHei";font-size:24px;font-weight:bold}
div.subtitle{font-family:"Verdana";font-size:18px;font-weight:bold}
div.boxtitle-1{margin:0px;padding:6px;width:200px;height:28px;color:#FFFFFF;text-align:center;font-family:"Microsoft YaHei";font-size:18px;font-weight:bold;background-color:#006EDC}
div.boxcontent-1{margin:0px;padding:4px 0px 0px 0px;height:150px;border-top:6px solid #1E90FF;clear:both}
div.errordescription{padding:8px;font-family:"Microsoft YaHei";font-size:15px;background-color:#DDDDDD}
div.buttonbackground{padding:12px;text-align:center;background-color:#999999}
</style>
<br/>
<div class="frametitle">数据获取成功</div><br/><br/>
<div class="boxtitle-1">请稍后</div>
<div class="boxcontent-1">
<div class="errordescription"><b>成功从哔哩哔哩开放平台获取数据,正在刷新页面,请稍后...</b></div><br/>
数据已写入缓存数据库...<br/><br/>
<div class="buttonbackground"><input type="button" class="button" value="刷新" onclick="document.location.reload()"> <input type="button" class="button" value="帮助" onclick="window.open(\'/?about\')"></div>
';
}
if ($refresh==1)
{
echo '<script language="javascript" type="text/javascript">function Refresh(){window.location.href="/api/do.php?act=info&av='.$_GET["av"].'&page='.$page.'"}</script>';
}
}
if ($update==0)
{
if (!empty($error))