die($error_no_id['value']);
}
$id = $_GET['id'];
if (!youtube_validate_id($id)) {
    die($error_invalid_id['value']);
}
if (!var_check($_GET['type'])) {
    die($error_no_caption_format['value']);
}
$type = strtolower($_GET['type']);
if (!in_array($type, $caption_format)) {
    die($error_caption_format_not_exist['value']);
}
$edit = var_check($_GET['edit'], True);
$video = new Youtube($id);
$data = $video->get_asr_caption($edit);
if ($data == False) {
    die("No captions");
}
if (var_check($_GET['dl'])) {
    // Download it.
    header('Content-Transfer-Encoding: binary');
    if ($edit) {
        header(sprintf("Content-Disposition: attachment; filename=\"asr_%s_corrected.%s\"", $id, $type));
    } else {
        header(sprintf("Content-Disposition: attachment; filename=\"asr_%s.%s\"", $id, $type));
    }
}
switch ($type) {
    case "vtt":
        header("Content-Type: text/vtt");