forked from jeckman/YouTube-Downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getimage.php
39 lines (36 loc) · 1.42 KB
/
getimage.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
<?PHP
include_once('config.php');
$my_id=$_GET["videoid"];
if(isset($_REQUEST['videoid'])) {
$my_id = $_REQUEST['videoid'];
if(strlen($my_id)>11){
$url = parse_url($my_id);
$my_id = NULL;
if( is_array($url) && count($url)>0 && isset($url['query']) && !empty($url['query']) ){
$parts = explode('&',$url['query']);
if( is_array($parts) && count($parts) > 0 ){
foreach( $parts as $p ){
$pattern = '/^v\=/';
if( preg_match($pattern, $p) ){
$my_id = preg_replace($pattern,'',$p);
break;
}
}
}
if( !$my_id ){
echo '<p>No video id passed in</p>';
exit;
}
}else{
echo '<p>Invalid url</p>';
exit;
}
}
} else {
echo '<p>No video id passed in</p>';
exit;
}
$thumbnail_url="http://i1.ytimg.com/vi/".$my_id."/default.jpg"; // make image link
header("Content-Type: image/jpeg"); // set headers
readfile($thumbnail_url); // show image
?>