Q:

python download youtube video

from __future__ import unicode_literals
import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['VideoURL'])
4
# run python -m pip install git+https://github.com/nficano/pytube
# VERY IMPORTANT, IT WILL NOT WORK IF YOU DON'T RUN THAT

import pytube

url = 'https://www.youtube.com/YoutubeLinkGoesHere'
video = pytube.YouTube(url)
stream = video.streams.get_by_itag(22)
stream.download(filename='video')
1
<script src="http://www.youtube.com/player_api"></script>

<div id="player" style="position: absolute; top: -9999px; left: -9999px;"></div>
<div id="info">loading...</div>
<script src="http://www.youtube.com/player_api"></script>
<script>
var info = document.getElementById('info');
function onYouTubePlayerAPIReady() {
  var player = new YT.Player('player', {
      videoId: 'gzeOWnnSNjg', // this is the id of the video at youtube (the stuff after "?v=")
      loop: true,
      events: {
          onReady: function (e) {
              info.innerHTML = 'video is loaded';
              e.target.playVideo();
          },
          onStateChange: function (event) {
              if (event.data === 1) {
                  info.innerHTML = 'video started playing';
              }
          }
      }
  });
  // you can do more stuff with the player variable
}
</script>
0
youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 <Video-URL>
0
>>> from pytube import YouTube
>>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download()
-3
from pytube import YouTube #pip install pytube3
yt=YouTube(YouTubeVideoLink)
stream=yt.streams.first()
stream.download()
-3

New to Communities?

Join the community