I have a problem using the yt-dlp library to download videos from YouTube
When getting the name of a video, sometimes the program gives out the wrong name, which does not exist at all
I use php for the query
Can you tell me how to make more stable queries to get the name of the video?
your text
$metadata_command = “$yt_dlp_path –dump-json –verbose “$user_url””;
your text
$metadata_output = [];
your text
$metadata_return_var = 0;
your text
exec($metadata_command, $metadata_output, $metadata_return_var);
your text
if ($metadata_return_var !== 0) {
your text
echo “Metadata retrieval error: ” . implode(“n”, $metadata_output);
your text
throw new Exception(‘Metadata retrieval error video from YouTube’);
your text
}
your text
if ($metadata_return_var === 0) {
your text
$metadata = json_decode(implode(“n”, $metadata_output), true);
your text
if ($metadata === null) {
your text
throw new Exception(‘Error decoding JSON metadata.’);
your text
}
your text
$video_title = $metadata[‘title’];
your text
}
I tried to find mentions of a similar error on the Internet, but to no avail