Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
[+]适配DanDanPlay概念版4.0.4远程访问功能;
Browse files Browse the repository at this point in the history
[↑]更改远程访问缩略图提供方式
  • Loading branch information
CberYellowstone committed Sep 30, 2021
1 parent e17e19e commit 73b3280
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api/v1/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule library api.php?action=library
RewriteRule playlist api.php?action=gettest
RewriteRule current/video api.php?action=clcache
RewriteRule ^image/id/(.*)$ api.php?action=image&id=$1
RewriteRule ^stream/id/(.*)$ api.php?action=stream&id=$1
RewriteRule ^image/(.*)$ api.php?action=image&id=$1
RewriteRule ^stream/(.*)$ api.php?action=stream&id=$1
RewriteRule ^comment/(.*)$ api.php?action=comment&id=$1
Expand Down
21 changes: 17 additions & 4 deletions api/v1/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function mkJsonIndexForFolder($folder_path){
$video_path = $video_information_list['file_path'];
$video_parent_path_md5 = md5(getFileName(dirname($video_path),TRUE));
$video_file_md5 = md5(getFileName($video_path));
$video_path = str_replace($GLOBALS['video_root_path'],'','A:'.$video_path);
$video_path = str_replace('/','\\',$video_path);
$video_path = str_replace('\\','\\\\',$video_path);
//$last_time = readLastTime($each_video_path);
Expand All @@ -82,16 +83,28 @@ function mkJsonIndexForRoot($root){
echo ("]");
}

function showImg($img){
$info = getimagesize($img);
$imgExt = image_type_to_extension($info[2], false); //获取文件后缀
$fun = "imagecreatefrom{$imgExt}";
$imgInfo = $fun($img); //1.由文件或 URL 创建一个新图象。如:imagecreatefrompng ( string $filename )
//$mime = $info['mime'];
$mime = image_type_to_mime_type(exif_imagetype($img)); //获取图片的 MIME 类型
header('Content-Type:'.$mime);
$quality = 100;
if($imgExt == 'png') $quality = 9; //输出质量,JPEG格式(0-100),PNG格式(0-9)
$getImgInfo = "image{$imgExt}";
$getImgInfo($imgInfo, null, $quality); //2.将图像输出到浏览器或文件。如: imagepng ( resource $image )
imagedestroy($imgInfo);
}

function sendVideoPicFromMD5($md5){
$parent_md5 = explode("-",$md5)[0];
$video_md5 = explode("-",$md5)[1];
if($GLOBALS['able_webp']){
@ header("Content-Type:image/webp");
echo (file_get_contents(($GLOBALS['data_path'].'/'.$parent_md5.'/'.$video_md5.'/'.$video_md5.'.webp')));
showImg(($GLOBALS['data_path'].'/'.$parent_md5.'/'.$video_md5.'/'.$video_md5.'.webp'));
} else {
@ header("Content-Type:image/jpeg");
echo (file_get_contents(($GLOBALS['data_path'].'/'.$parent_md5.'/'.$video_md5.'/'.$video_md5.'.jpg')));
showImg(($GLOBALS['data_path'].'/'.$parent_md5.'/'.$video_md5.'/'.$video_md5.'.jpg'));
}
}

Expand Down

0 comments on commit 73b3280

Please sign in to comment.