I've just started programming a few weeks ago so keep in mind I have no idea what exactly I'm doing.
I'm attempting to create an little website in which you input a youtube url and it'll download the video in an mp3 format and play it back to you with the audio visualizer. I've got almost everything working except the downloading part.
When I input a url and submit it instead of downloading the youtube video it downloads the php file in which the code resides.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="main.css">
<script src="prefixfree.min.js"></script>
</head>
<body>
<div id="main">
<h1 id="header">Audio Visualizer</h1>
<div id="form" class="container-center">
<form action="download.php" method="get">
<input class="t-input" name="url" type="text" placeholder=" enter youtube video URL here">
<br>
<input class="submit" type="submit" name="submit">
</form>
</div>
</div>
<script src="sketch/sketch.min.js"></script>
<script src="animation.js"></script>
</body>
</html>
PHP
<?php
$url = $_GET['url'];
try {
new yt_downloader($url, TRUE, 'audio');
}
catch (Exception $e) {
die($e->getMessage());
}
The downloader incase that's important: https://github.com/eyecatchup/php-yt_downloader/
So far I've only been messing around with javascript so, I have no idea how php works. I assume I've made some newbie mistake somewhere above which I can't fine.
Thank for the help!
EDIT: As Joel Hinz has pointed out I failed to download ffmpeg, unfortunately it still appears to not be working :(
SOURCE OF PROBLEM FOUND: It appears xampp doesn't want to run ffmpeg.
Firstly, congrats for getting this far after a few weeks!
For most programming problems, the best approach to debugging when you get beyond intuitive 'guesses', which are fine as a first pass, is to take the slow and thorough approach to step through and see exactly what is happening.
For your problem:
<?php
if (isset($_GET['url'])) {
echo $_GET['url'];
}else{
echo "Error: url is not set";
}
.
. (the rest of your PHP code here)
.
?>
Hopefully, this helps point you in the right directions (it is really more of a 'comment' than an answer but wouldn't fit in the comment section!).
Good Luck...