Created
May 7, 2016 17:40
-
-
Save bzz0217/4cb8a5e2615ee7935239732e2ee1027c to your computer and use it in GitHub Desktop.
動画ダウンローダ - フロントエンド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//ini_set("display_errors", 1); | |
//error_reporting(-1); | |
ini_set("max_execution_time", 0); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>動画ダウンロード</title> | |
<!-- Latest compiled and minified CSS --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
<!-- Optional theme --> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> | |
<!-- Latest compiled and minified JavaScript --> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> | |
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css"> | |
<style> | |
#wrapper{ | |
width:1000px; | |
margin:10px 20px; | |
} | |
.table{ | |
width:800px; | |
margin-top:50px; | |
} | |
.url{ | |
width:500px; | |
} | |
.error_msg{ | |
color: #c0392b; | |
font-weight: 800; | |
} | |
.detail_msg{ | |
color:#c0c0c0; | |
font-size:12px; | |
} | |
.link_btn{ | |
padding: 10px 20px; | |
border: 1px solid #c0c0c0; | |
width: 110px; | |
font-weight: 800; | |
} | |
#output{ | |
margin-top:5px; | |
} | |
.right { | |
text-align: right; | |
} | |
.form_area{ | |
margin:20px 0px; | |
} | |
.title{ | |
margin-left:10px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="wrapper"> | |
<h1><i class="fa fa-film" aria-hidden="true"></i><span class="title">動画ダウンロード</span></h1> | |
<form method="post"> | |
<div class="form_area"> | |
<label>動画URL:</label> | |
<input type="text" name="url" class="url" placeholder="http://" value="<?php | |
if (isset($_POST['url'])){ | |
echo htmlspecialchars($_POST['url'], ENT_QUOTES, "UTF-8"); | |
} | |
?>"> | |
<input class="btn btn-primary" type="submit" value="保存"> | |
</div> | |
</form> | |
<?php | |
if (isset($_POST['url'])){ | |
require_once('youtube_dl_run_progress.php'); | |
require_once('youtube_dl_get_info.php'); | |
//動画情報取得 | |
$info = new youtube_dl_get_info(); | |
$movie_info = $info->command($_POST['url']); | |
if ($movie_info['error_code']==0){ | |
$movie_path = "/var/www/html/anime_download/movie/"; | |
$time = date("YmdHis"); | |
}else{ | |
if (preg_match($ERROR_PATTERN, $msg[0], $code)){ | |
$movie_info['error_code'] = $code[1]; | |
$movie_info['error_info'] = $code[2]; | |
} | |
$movie_info['error_msg'] = $msg[0]; | |
} | |
if (empty($movie_info['error_msg'])){ | |
echo <<<EOF | |
<table class="table"> | |
<tr> | |
<th>サムネイル</th> | |
<th>動画タイトル</th> | |
<th>進捗状況</th> | |
<th>残り時間</th> | |
<th>ダウンロード速度</th> | |
<th>ファイルサイズ</th> | |
</tr> | |
<tr> | |
<td><img src="{$movie_info['thumbnail']}" width="100px"></td> | |
<td><a href="{$_POST['url']}" target="_blank">{$movie_info['title']}</a></td> | |
<td id="bar_area"><progress value="0" max="100" id="progress_bar">Loading...</progress><div id="output">0%</div></td> | |
<td id="full_time" class="right"></td> | |
<td id="dl_speed" class="right"></td> | |
<td id="filesize" class="right"></td> | |
</tr> | |
</table> | |
EOF; | |
}else{ | |
echo "<div class='error_msg'>その動画はダウンロードできません</div>"; | |
echo "<div class='detail_msg'>" . $movie_info['error_msg'] . "</div>"; | |
} | |
if (empty($movie_info['error_msg'])){ | |
//------------------------ | |
//ダウンロード開始 | |
//------------------------ | |
$output_path = "/var/www/html/anime_download/movie/"; | |
$time = date("YmdHis"); | |
//ダウンロード実行・進捗 | |
youtube_dl_run_progress::$config = array( | |
'time' => $time, | |
'output_path' => $output_path, | |
'url' => $_POST['url'] | |
); | |
$prg = new youtube_dl_run_progress(); | |
$prg->output_buffer(); | |
$download_url = $prg->progress_output(); | |
echo "<div class='link_btn'>"; | |
echo " <a href='" . $download_url . "' target='_blank'>動画を見る</a>"; | |
echo "</div>"; | |
} | |
} | |
?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment