test
This commit is contained in:
parent
fa99cd2251
commit
49307515c8
@ -64,7 +64,7 @@ async def dropoutDownload(
|
|||||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||||
|
|
||||||
@app.post("/ydl")
|
@app.post("/ydl")
|
||||||
async def ydl(url: str, location: str):
|
async def ydl(url: str = Form(...), location: str = Form(...)):
|
||||||
try:
|
try:
|
||||||
await loop.run_in_executor(None, partial(download.youtube.ydl, url, location))
|
await loop.run_in_executor(None, partial(download.youtube.ydl, url, location))
|
||||||
# download.youtube.ydl(url,location)
|
# download.youtube.ydl(url,location)
|
||||||
|
|||||||
@ -47,40 +47,45 @@
|
|||||||
<!-- {navBar} -->
|
<!-- {navBar} -->
|
||||||
<form id="ydl_download">
|
<form id="ydl_download">
|
||||||
<input class="downloader" name="url" type="text" id="download_field" placeholder="Enter URL">
|
<input class="downloader" name="url" type="text" id="download_field" placeholder="Enter URL">
|
||||||
|
|
||||||
<select class="downloader" name="location" id="download_location">
|
<select class="downloader" name="location" id="download_location">
|
||||||
<option value="/nsfw">NSFW</option>
|
<option value="/nsfw">NSFW</option>
|
||||||
<option value="/podcasts">Podcast</option>
|
<option value="/podcasts">Podcast</option>
|
||||||
<option value="/asmr">ASMR</option>
|
<option value="/asmr">ASMR</option>
|
||||||
<option value="/youtube">YouTube</option>
|
<option value="/youtube">YouTube</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
<button class="downloader" type="submit">Download</button> <!-- Added a submit button -->
|
|
||||||
|
<button class="downloader" type="submit">Download</button>
|
||||||
</form>
|
</form>
|
||||||
<div id="downloadResult"></div>
|
<div id="downloadResult"></div>
|
||||||
</body>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function clearInput() {
|
function clearInput() {
|
||||||
$('#download_field').val(''); // Clear the input field
|
$('#download_field').val(''); // Clear the input field
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the form submission with AJAX
|
$(document).ready(function () {
|
||||||
$(document).ready(function () {
|
$('#ydl_download').submit(function (event) {
|
||||||
$('#ydl_download').submit(function (event) {
|
event.preventDefault(); // Prevent default form submission
|
||||||
event.preventDefault(); // Prevent the default form submission
|
alert("File is now downloading..."); // Placeholder, can be replaced with a loading spinner
|
||||||
alert("File is now downloading");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST', // Use POST method to send data
|
type: 'POST',
|
||||||
url: '/ydl', // Target URL for the CherryPy handler
|
url: '/ydl', // URL for handling the request on the server
|
||||||
data: $('#ydl_download').serializeArray(), // Serialize the form data
|
data: $('#ydl_download').serializeArray(), // Serialize form data
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$('#downloadResult').html(data); // Display the result in the specified div
|
$('#downloadResult').html(data); // Show server response
|
||||||
alert("File has finished downloading");
|
alert("File has finished downloading"); // Update as necessary
|
||||||
}
|
clearInput(); // Clear the form fields after download is finished
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
alert("An error occurred during the download process. Please try again.");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
</script>
|
||||||
</script>
|
|
||||||
<!-- <script type="text/javascript" src="/static/javascript/ydl.js"></script> -->
|
<!-- <script type="text/javascript" src="/static/javascript/ydl.js"></script> -->
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user