forked from ArdiArtani/Photo-Google-Player-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgp.php
137 lines (131 loc) · 4.22 KB
/
gp.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
<?php
function curl($url) {
$ch = @curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$head[] = "Connection: keep-alive";
$head[] = "Keep-Alive: 300";
$head[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$head[] = "Accept-Language: en-us,en;q=0.5";
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$page = curl_exec($ch);
curl_close($ch);
return $page;
}
function posterImg($url, $size = "1280,720") { //poster size width,height
$internalErrors = libxml_use_internal_errors(true);
$ch = curl_init();
$timeout = 30;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);
$sizes = explode(",",$size);
$dom = new DOMDocument();
@$dom->loadHTML($html);
libxml_use_internal_errors($internalErrors);
$maximgx = 1;
$imgx = "";
foreach($dom->getElementsByTagName('img') as $element) {
($maximgx <= 1) ? $maximgx++ && $imgx = $element->getAttribute('src') : '';
}
$xim = str_replace("=w214-h120-k-no","=w".$sizes[0]."-h".$sizes[1]."-no",$imgx);
return $xim;
}
function getPhotoGoogle($link){
$get = curl($link);
$files = "";
$data = explode('url\u003d', $get);
if (isset($data[1])) {
$url = explode('%3Dm', $data[1]);
$decode = urldecode($url[0]);
} else {
$decode = "";
}
$count = count($data);
$linkDownload = array();
$v1080p = $decode.'=m37';
$v720p = $decode.'=m22';
$v360p = $decode.'=m18';
if($count > 7) {
$linkDownload['1080p'] = $v1080p;
$linkDownload['720p'] = $v720p;
$linkDownload['360p'] = $v360p;
} else if($count > 3) {
$linkDownload['720p'] = $v720p;
$linkDownload['360p'] = $v360p;
} else if($count > 2) {
$linkDownload['360p'] = $v360p;
} else if($count >= 0) {
$linkDownload['direct'] = dwnload($link);
}
foreach ($linkDownload as $key => $l){
$files .= '{"type": "video/mp4", "label": "'.$key.'", "file": "'.$l.'"},';
}
if(@!$files) {
$files = '{"type": "video/mp4", "label": "HD", "file": "'.$decode .'=m18'.'"}';
}else{
return '['.rtrim($files, ',').']';
}
}
//download video directly or stream in player without range request headers.
function dwnload($url) {
$scriptx = "";
$internalErrors = libxml_use_internal_errors(true);
$dom = new DOMDocument();
@$dom->loadHTML(curl($url));
foreach($dom->getElementsByTagName('script') as $k => $js) {
$scriptx .= $js->nodeValue;
}
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $scriptx, $match);
$vlink = "";
foreach ($match[0] as $c) {
if (strpos($c, 'video-downloads') !== false) {
$vlink = $c;
}
}
return $vlink; //video-downloads.googleusercontent.com - no range headers
}
function fetch_value($str, $find_start = '', $find_end = ''){
if ($find_start == '') {
return '';
}
$start = strpos($str, $find_start);
if ($start === false) {
return '';
}
$length = strlen($find_start);
$substr = substr($str, $start + $length);
if ($find_end == '') {
return $substr;
}
$end = strpos($substr, $find_end);
if ($end === false) {
return $substr;
}
return substr($substr, 0, $end);
}
function getURLbyID($id){
$url="https://goo.gl/photos/$id";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Must be set to true so that PHP follows any "Location:" header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$a = curl_exec($ch); // $a will contain all headers
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); // This is what you need, it will return you the last effective URL
$photoid = fetch_value(file_get_contents($url), '[null,[["', '",');
$substr = '?key';
$fullurl = '/photo/'.$photoid;
$gpurl = str_replace($substr, $fullurl.$substr, $url);
return $gpurl;
}
?>