Skip to content

Commit a0d5807

Browse files
Return error if no "v" parameter was specified
1 parent 4f6ed85 commit a0d5807

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

convert.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,31 @@
1313
$youtubelink = $_GET["youtubelink"];
1414

1515
parse_str(parse_url($youtubelink, PHP_URL_QUERY), $queryvars);
16+
17+
if(!array_key_exists("v", $queryvars))
18+
{
19+
die(json_encode(array("error" => true, "message" => "No video specified")));
20+
}
21+
1622
$id = $queryvars["v"];
1723
$file = DOWNLOAD_FOLDER.$id.".mp3";
1824

1925
$exists = file_exists($file);
2026
if($exists)
2127
{
22-
$options = [
28+
$options = array(
2329
'skip-download' => true
24-
];
30+
);
2531
}
2632
else
2733
{
28-
$options = [
34+
$options = array(
2935
'extract-audio' => true,
3036
'audio-format' => 'mp3',
3137
'audio-quality' => 0,
3238
'output' => '%(id)s.%(ext)s',
3339
//'ffmpeg-location' => '/usr/local/bin/ffmpeg'
34-
];
40+
);
3541
}
3642
$dl = new YoutubeDl($options);
3743

@@ -47,7 +53,7 @@
4753
$file = DOWNLOAD_FOLDER_PUBLIC.$video->getFilename();
4854

4955
echo json_encode(array("error" => false, "title" => $video->getTitle(), "duration" => $video->getDuration(), "file" => $file));
50-
}
56+
}
5157
catch (Exception $e)
5258
{
5359
echo json_encode(array("error" => true, "message" => $e->getMessage()));

0 commit comments

Comments
 (0)