Create thumbnail.youtube.php

This commit is contained in:
Namhyeon Go 2019-10-25 11:49:54 +09:00 committed by GitHub
parent 1ebba738d8
commit ef90fa3045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,36 @@
<?php
if(!check_function_exists("get_youtube_thumbnail")) {
function get_youtube_thumbnail($vi) {
$ytimgs = array();
$ytimg_urls = array();
$ytimg_url = "http://img.youtube.com/vi/:vi/:rs.jpg";
$ytimg_types = array(
"t0" => "0",
"t1" => "1",
"t2" => "2",
"t3" => "3",
"de" => "default",
"mq" => "mqdefault",
"hq" => "hqdefault",
"sd" => "sddefault",
"mx" => "maxresdefault"
);
foreach($ytimg_types as $k=>$v) {
$url = get_web_binded_url($ytimg_url, array(
"vi" => $vi,
"rs" => $v
));
$response = get_web_page($url, "get.cache");
$ytimgs[$k] = $response['content'];
$fpath = write_storage_file($response['content'], array(
"filename" => $response['sha1']
));
$ytimg_urls[$k] = get_storage_url() . "/" . $response['sha1'];
}
return $ytimg_urls;
}
}