Skip to content

Commit

Permalink
Create thumbnail.youtube.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 authored Oct 25, 2019
1 parent 1ebba73 commit ef90fa3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions helper/thumbnail.youtube.php
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit ef90fa3

Please sign in to comment.