我编写了一个简单的youtube下载程序
这是代码:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="jumbotron text text-center">
<h1>Settings</h1>
</div>
<div class="container justify-content-center">
<h2>Pushup # time / # seconds</h2>
<h2>Pullup # time / # seconds</h2>
<h2>Squats # time / # seconds</h2>
<form action='./settings.html'>
<h1>Pushups</h1>
<img src="https://media.tenor.com/images/28fecfea6b4a7c36c7e45c76fe86b3b8/tenor.gif" alt="pushup gif" /><br>
<label for="pushupQuantity">Pushup Quantity: </label>
<input type="text" id="pushupQuantity" name="pushupQuantity" value="30"><br>
<label for="pushupTime">Seconds in between: </label>
<input type="text" id="pushupTime" name="pushupTime" value="2"><br>
<hr>
<h1>Pullups</h1>
<img src="https://thumbs.gfycat.com/FailingSlushyBoa-size_restricted.gif" alt="pullup gif" /><br>
<label for="pullupQuantity">Pullup Quantity: </label>
<input type="text" id="pullupQuantity" name="pullupQuantity" value="40"><br>
<label for="pullupTime">Seconds in between: </label>
<input type="text" id="pullupTime" name="pullupTime" value="4"><br>
<hr>
<input class="btn btn-primary" type="submit" value="Submit">
</form>
</div>
执行此代码时,出现此错误:
YouTube("https://youtu.be/7nXt6oggOlE").streams.first().download()
答案 0 :(得分:2)
这是我最近使用的
from pytube import YouTube
import os
link = "https://www.youtube.com/watch?v=wl8X-kV-gmU&ab_channel=MixHound"
path = 'C:\\YouTube_download_path'
def downloadYouTube(videourl, path):
yt = YouTube(videourl)
yt = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
if not os.path.exists(path):
os.makedirs(path)
yt.download(path)
downloadYouTube(link, path)
答案 1 :(得分:1)
尝试一下对我有用。它也可以解决您的问题。
pip uninstall pytube
pip uninstall pytube3
python -m pip install git+https://github.com/nficano/pytube