title: Download only audio from youtube video using youtube-dl in python script
body: <p>There's a <a href="https://stackoverflow.com/questions/14185867/extract-audio-with-youtube-dl-on-windows">few</a> <a href="https://stackoverflow.com/questions/15241076/download-only-audio-from-a-youtube-video">posts</a> on <a href="https://stackoverflow.com/questions/2884588/streaming-audio-youtube">downloading audio</a> from YouTube using <code>youtube-dl</code>, but none of them are concrete or too helpful. I'm wondering what the best way to do it from a Python script is.</p>
  <p>For example, here's the README example for downloading videos:</p>
  <pre><code>import youtube_dl
  
  ydl_opts = {}
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
      ydl.download(['http://www.youtube.com/watch?v=BaW_jenozKc'])
  </code></pre>
  <p>Obviously if you just care about the audio, you'd rather not download the whole video...</p>
  <p>Therefore, the <a href="https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L74" rel="noreferrer">youtube-dl</a> source isn't very helpful</p>
  <p>Any suggestions on how to script this?</p>