1

400 曲のタイトルのリストがあり、検索結果ページにハイパーリンクされています。例の写真

youtube-dl と J Downloader の両方を持っていますが、動画の検索 URL のリストから高品質の mp3 をダウンロードするために youtube-dl で必要なパラメーターがわかりません。すべての検索から最初のビデオをmp3としてダウンロードするだけです。

4

2 に答える 2

0

あなたの質問は、リストの残りの部分で何をしようとしているのかを正確に説明していません。とにかく、最初のリンクの MP3 を取得する方法を紹介します。

  1. まず、URL をコンマ (,) で区切ります
  2. PHPでファイル全体を取得します

    $file = 'path_to_file';
    $data = file_get_contents($file);
    
  3. リストを配列に変換する

    $songs_list = explode(",", $data);
    
  4. カウントを設定し、配列をループします

    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
             }
       }
    ?>
    
于 2016-04-02T06:41:57.590 に答える