gpt4 book ai didi

javascript - 无需点击 PHP 脚本即可自动打开 URL

转载 作者:行者123 更新时间:2023-11-28 05:44:24 25 4
gpt4 key购买 nike

我编写了一个PHP脚本,用于下载任何YouTube视频,它适用于2个按钮,第一个按钮用于创建格式,第二个按钮开始下载,我希望如果我按下第一个按钮,第二个按钮,自动完成其工作,并单击开始下载,

这是第一个按钮的代码,

<button id="videoDownloadButton" type="button" class="btn btn-info btn-lg"          data-toggle="modal" data-target="#myModal" onClick="downloadVideo();">MP4 Quality</button>

该按钮上的 Javssript 是......

function downloadVideo() {
var videoID = player.getVideoData()['video_id']
document.getElementById("downloadFormatList").innerHTML="Please wait. Processing...";
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp3 = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp3.onreadystatechange=function() {
if (xmlhttp3.readyState==4 && xmlhttp3.status==200) {
document.getElementById("downloadFormatList").innerHTML=xmlhttp3.responseText;
}
}

//keyword = keyword.replace(/ /g, '%2B');
xmlhttp3.open("GET","TMB/download.php?videoid="+videoID,true);
xmlhttp3.send();

}

之后 PHP 脚本将运行并生成第二个按钮,这是一个 HTML 标签,

if(isset($_REQUEST['videoid'])) {
$my_id = $_REQUEST['videoid'];

if(strpos($my_id,"https://youtu.be/") !== false)
{
$my_id = str_replace("https://youtu.be/","",$my_id);
}
}


<?php

//$my_video_info = 'http://www.youtube.com/get_video_info?&video_id='. $my_id;
$my_video_info = 'http://www.youtube.com/get_video_info?&video_id=' . $my_id . '&asv=3&el=detailpage&hl=en_US'; //video details fix *1
$my_video_info = curlGet($my_video_info);
/* TODO: Check return from curl for status code */
$thumbnail_url = $title = $url_encoded_fmt_stream_map = $type = $url = '';
parse_str($my_video_info);
?>



<?php
$my_title = $title;
$cleanedtitle = clean($title);
if (isset($url_encoded_fmt_stream_map)) {
/* Now get the url_encoded_fmt_stream_map, and explode on comma */
$my_formats_array = explode(',', $url_encoded_fmt_stream_map);
if ($debug) {
echo '<pre>';
print_r($my_formats_array);
echo '</pre>';
}
} else {
echo '<p>No encoded format stream found.</p>';
echo '<p>Here is what we got from YouTube:</p>';
echo $my_video_info;
}
if (count($my_formats_array) == 0) {
echo '<p>No format stream map found - was the video id correct?</p>';
exit;
}
/* create an array of available download formats */
$avail_formats[] = '';
$i = 0;
$ipbits = $ip = $itag = $sig = $quality = '';
$expire = time();
foreach ($my_formats_array as $format) {
parse_str($format);
$avail_formats[$i]['itag'] = $itag;
$avail_formats[$i]['quality'] = $quality;
$type = explode(';', $type);
$avail_formats[$i]['type'] = $type[0];
$avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
parse_str(urldecode($url));
$avail_formats[$i]['expires'] = date("G:i:s T", $expire);
$avail_formats[$i]['ipbits'] = $ipbits;
$avail_formats[$i]['ip'] = $ip;
$i++;
}


echo '<div class="format_list">';
echo '<br>';
echo '<table>';

/* now that we have the array, print the options */
for ($i = 0; $i < 1; $i++) {
if ($config['VideoLinkMode'] == 'direct' || $config['VideoLinkMode'] == 'both')
?> <tr><td><?php
echo $avail_formats[$i]['type'];
?></td>

<td><small>(<?php
echo $avail_formats[$i]['quality'];
?>)</small> </td>
<td><small><span class="size"><?php
echo formatBytes(get_size($avail_formats[$i]['url']));
?></span></small>
</td>

<td><a href="<?php
echo $avail_formats[$i]['url'];
?> '&title='<?php
echo $cleanedtitle;
?>'" class="downloadButton">Record Video</a></td>
</tr>
<?php
}
?>

这是按钮,我想自动完成它的工作

<a href="<?php
echo $avail_formats[$i]['url'];
?> '&title='<?php
echo $cleanedtitle;
?>'" class="downloadButton">Record Video</a>

最佳答案

尝试这个而不是第二个按钮代码。

header('Location:' .$avail_formats[$i][url]. '&title=' .$cleanedtitle);

关于javascript - 无需点击 PHP 脚本即可自动打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38662723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com