forked from wukes/youtube-php-mirroring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_video.php
143 lines (120 loc) · 3.82 KB
/
m_video.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
<?php
$v=$_GET[v];
//判断设备
if(empty($v)){
$g_et='true';
}
function fcurl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function isMobile(){
$useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:'';
function CheckSubstrs($substrs,$text){
foreach($substrs as $substr)
if(false!==strpos($text,$substr)){
return true;
}
return false;
}
$mobile_os_list=array('Google Wireless Transcoder','Windows CE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','Opera Mobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');
$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');
$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock) ||
CheckSubstrs($mobile_token_list,$useragent);
if ($found_mobile){
return true;
}else{
return false;
}
}
if (isMobile()){}
else{
//如果电脑访问
header("Location: video.php?v=$v");
//确保重定向后,后续代码不会被执行
exit;
}
//获取原始下载地址
//require 'inc/parser.php';
$parserurl='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"];
$parserurl=dirname($parserurl);
$geturl= $parserurl.'/parser/index.php?videoid='."$v";
$w=fcurl($geturl);
$cv=json_decode($w);
//print_r($cv);
//echo $cv[Download][1][url];
function object_array($array)
{
if(is_object($array))
{
$array = (array)$array;
}
if(is_array($array))
{
foreach($array as $key=>$value)
{
$array[$key] = object_array($value);
}
}
return $array;
}
$rr=object_array($cv);
$aaaks=array_reverse(($rr[Download]));
$vname=$rr[title];//视频名称
$pagetitle=$vname;
//加密传输视频
// Declare the class
require 'pheader.php';
$API_key=$youtube_api;
$jsonurl='https://www.googleapis.com/youtube/v3/search?part=snippet&order=relevance&regionCode=lk&key='.$API_key.'&part=snippet&maxResults=20&relatedToVideoId='.$v.'&type=video';
//To try without API key: $video_list = json_decode(file_get_contents(''));
$video_list = json_decode(fcurl($jsonurl));
$video_list1=object_array($video_list);
require 'header.php';
?>
<script src="js/jquery.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<div class="wrapper container">
<?php
if($g_et!=true){
echo <<<EOT
<div class="row">
<div class="col-xs-12" id="video" style="z-index:-1000">
<!--ckplayer配置开始-->
<video controls="controls" poster="./thumbnail.php?vid=$v" autoplay="autoplay" width="100%" height="100%">
<source src="./mpaly.php?id=$v" type="video/mp4" />
您的浏览器不支持HTML5播放MP4.
</video>
<!--ckplayer配置结束-->
</div>
<div class="col-xs-12">
<h3>$vname</h3>
EOT;
}else{
echo '<div class="alert alert-danger">错误!非法请求。</div>';
}
?>
</div>
<div class="col-xs-12">
<a href="#"
class="list-group-item active">
相关视频
</a>
<?php
for($i=0;
$i<=20;$i++){
echo'<a href="video.php?v='.$video_list1[items]
[$i][id][videoId] .'"target="_blank" class="list-group-item">'.
$video_list1[items][$i][snippet][title].'</a>';
}
?>
</div>
</div>
</div>
<?php require 'footer.php';?>