1from pytube import YouTube
2import os
3from pathlib import Path
4
5link = input("Enter link here: ")
6
7url = YouTube(link)
8
9print("downloading....")
10
11video = url.streams.get_highest_resolution()
12
13path_to_download_folder = str(os.path.join(Path.home(), "Downloads"))
14
15video.download(path_to_download_folder)
16print("Downloaded! :)")
1import YouTube from pytube
2
3yt = YouTube(url)
4t = yt.streams.filter(only_audio=True)
5t[0].download(/path)
1youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 <Video-URL>
2
1from __future__ import unicode_literals
2import youtube_dl
3
4ydl_opts = {}
5with youtube_dl.YoutubeDL(ydl_opts) as ydl:
6 ydl.download(['VideoURL'])
1#download pytube with pip install pytube
2import pytube
3
4#made it a function so that you can call it from any script and just pass in
5#the url in ""
6def downloadVideo(url):
7 youtube = pytube.YouTube(url)
8 video = youtube.streams.get_highest_resolution()
9 print(video.title)
10 video.download()
11
12
1<script src="http://www.youtube.com/player_api"></script>
2
3<div id="player" style="position: absolute; top: -9999px; left: -9999px;"></div>
4<div id="info">loading...</div>
5<script src="http://www.youtube.com/player_api"></script>
6<script>
7var info = document.getElementById('info');
8function onYouTubePlayerAPIReady() {
9 var player = new YT.Player('player', {
10 videoId: 'gzeOWnnSNjg', // this is the id of the video at youtube (the stuff after "?v=")
11 loop: true,
12 events: {
13 onReady: function (e) {
14 info.innerHTML = 'video is loaded';
15 e.target.playVideo();
16 },
17 onStateChange: function (event) {
18 if (event.data === 1) {
19 info.innerHTML = 'video started playing';
20 }
21 }
22 }
23 });
24 // you can do more stuff with the player variable
25}
26</script>