400 曲のタイトルのリストがあり、検索結果ページにハイパーリンクされています。例の写真
youtube-dl と J Downloader の両方を持っていますが、動画の検索 URL のリストから高品質の mp3 をダウンロードするために youtube-dl で必要なパラメーターがわかりません。すべての検索から最初のビデオをmp3としてダウンロードするだけです。
400 曲のタイトルのリストがあり、検索結果ページにハイパーリンクされています。例の写真
youtube-dl と J Downloader の両方を持っていますが、動画の検索 URL のリストから高品質の mp3 をダウンロードするために youtube-dl で必要なパラメーターがわかりません。すべての検索から最初のビデオをmp3としてダウンロードするだけです。
あなたの質問は、リストの残りの部分で何をしようとしているのかを正確に説明していません。とにかく、最初のリンクの MP3 を取得する方法を紹介します。
PHPでファイル全体を取得します
$file = 'path_to_file';
$data = file_get_contents($file);
リストを配列に変換する
$songs_list = explode(",", $data);
カウントを設定し、配列をループします
foreach ($songs_list as $key => $song) {
if ($count == 1) {
$commad = 'youtube-dl --extract-audio --audio-format mp3 youtube_video_url_here';
shell_exec($commad); // now audio of first video will be downloaded as MP3
} else {
// do the rest of your work on list
}
}
以下は完全なスクリプトです
<?php
$file = 'path_to_file';
$data = file_get_contents($file);
$songs_list = explode(",", $data);
$count = 1;
foreach ($songs_list as $key => $song) {
if ($count == 1) {
$commad = 'youtube-dl --extract-audio --audio-format mp3 youtube_video_url_here';
shell_exec($commad); // now audio of first video will be downloaded as MP3
} else {
// do the rest of your work on list
}
}
?>