标签: pytube

Pytube: urllib.error.HTTPError: HTTP 错误 410: 消失

我现在在几个程序上都遇到了这个错误。我尝试升级 pytube、重新安装它、尝试一些修复、更改 URL 和代码,但似乎没有任何效果。

from pytube import YouTube

#ask for the link from user
link = input("Enter the link of YouTube video you want to download:  ")
yt = YouTube(link)

#Showing details
print("Title: ",yt.title)
print("Number of views: ",yt.views)
print("Length of video: ",yt.length)
print("Rating of video: ",yt.rating)
#Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()

#Starting download
print("Downloading...")
ys.download()
print("Download completed!!")
Run Code Online (Sandbox Code Playgroud)

这是错误代码:

from pytube import YouTube

#ask for the link from user
link = input("Enter the link of YouTube video you …
Run Code Online (Sandbox Code Playgroud)

python http http-error pytube

21
推荐指数
4
解决办法
3万
查看次数

pytube:AttributeError:“NoneType”对象没有属性“span”

我刚刚下载了 pytube(版本 11.0.1)并从这里开始使用以下代码片段:

from pytube import YouTube
YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
Run Code Online (Sandbox Code Playgroud)

这给出了这个错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-29-0bfa08b87614> in <module>
----> 1 YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()

~/anaconda3/lib/python3.8/site-packages/pytube/__main__.py in streams(self)
    290         """
    291         self.check_availability()
--> 292         return StreamQuery(self.fmt_streams)
    293 
    294     @property

~/anaconda3/lib/python3.8/site-packages/pytube/__main__.py in fmt_streams(self)
    175         # https://github.com/pytube/pytube/issues/1054
    176         try:
--> 177             extract.apply_signature(stream_manifest, self.vid_info, self.js)                                                                            
    178         except exceptions.ExtractError:
    179             # To force an update to the js file, we clear the cache and retry                                                                           

~/anaconda3/lib/python3.8/site-packages/pytube/extract.py in apply_signature(stream_manifest, vid_info, js)                                                     
    407 
    408     """
--> 409     cipher = …
Run Code Online (Sandbox Code Playgroud)

python attributeerror pytube

15
推荐指数
4
解决办法
2万
查看次数

使用pytube下载mp3格式的视频

我一直在使用 pytube 在 python 中下载 youtube 视频。到目前为止,我已经能够以 mp4 格式下载。

yt = pytube.YouTube("https://www.youtube.com/watch?v=WH7xsW5Os10")

vids= yt.streams.all()
for i in range(len(vids)):
    print(i,'. ',vids[i])

vnum = int(input("Enter vid num: "))
vids[vnum].download(r"C:\YTDownloads")
print('done')
Run Code Online (Sandbox Code Playgroud)

我设法下载了“音频”版本,但它是.mp4格式的。我确实尝试将扩展名重命名为.mp3,并播放了音频,但应用程序(Windows Media Player)停止响应并开始滞后。

如何直接以音频文件.mp3格式下载视频?请提供一些代码,因为我是使用此模块的新手。

audio file-format youtube-api python-3.x pytube

12
推荐指数
2
解决办法
2万
查看次数

在 Pytube 中获取 Http 错误 404。这是什么原因?

错误信息/代码

此代码曾经在 4 天前工作,现在显示错误。我尝试使用 pytube3 但这没有帮助。

from pytube import YouTube** 
YouTube('https://www.youtube.com/watch?v=JbBsqmKclXE').streams**
Run Code Online (Sandbox Code Playgroud)

()
----> 1 YouTube('https://www.youtube.com/watch?v=JbBsqmKclXE').streams 中的HTTPError Traceback(最近一次调用最后一次)

14 帧
/usr/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)

647 class HTTPDefaultErrorHandler(BaseHandler):
648     def http_error_default(self, req, fp, code, msg, hdrs):
Run Code Online (Sandbox Code Playgroud)

--> 649 引发 HTTPError(req.full_url, code, msg, hdrs, fp) 650 651 类 HTTPRedirectHandler(BaseHandler):

HTTPError:HTTP 错误 404:未找到

python youtube-api http-error pytube

11
推荐指数
1
解决办法
7666
查看次数

如何使用pytube下载需要年龄验证的视频?

我使用 pytube 下载并剪辑一些 YouTube 视频,但有些视频未下载并要求年龄验证。我该如何解决这个问题?谢谢你的建议

python dataset pytube

10
推荐指数
1
解决办法
2万
查看次数

pytube.exceptions.RegexMatchError:__init__:找不到 ^\w+\W 的匹配项

所以我的问题是我运行这个简单的代码来尝试创建一个 pytube 流对象......

from pytube import YouTube

yt = YouTube('https://www.youtube.com/watch?v=aQNrG7ag2G4')
stream = yt.streams.filter(file_extension='mp4')
Run Code Online (Sandbox Code Playgroud)

并最终出现标题中的错误。

完整错误:

Traceback (most recent call last):
  File ".\test.py", line 4, in <module>
    stream = yt.streams.filter(file_extension='mp4')
  File "C:\Users\logan\AppData\Local\Programs\Python\Python38\lib\site-packages\pytube\__main__.py", line 292, in streams       
    return StreamQuery(self.fmt_streams)
  File "C:\Users\logan\AppData\Local\Programs\Python\Python38\lib\site-packages\pytube\__main__.py", line 184, in fmt_streams   
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "C:\Users\logan\AppData\Local\Programs\Python\Python38\lib\site-packages\pytube\extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "C:\Users\logan\AppData\Local\Programs\Python\Python38\lib\site-packages\pytube\cipher.py", line 33, in __init__
    raise RegexMatchError(
pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W
Run Code Online (Sandbox Code Playgroud)

额外数据:

python版本:3.8.10 pytube版本:11.0.2

python pytube

9
推荐指数
1
解决办法
1万
查看次数

下载视频时 Pytube keyerror 'streamData'

我正在编写一个代码,通过编写下面的代码来查看可用的视频流

from pytube import Playlist
from pytube import YouTube as YT
import threading as th
import time

plist=input('Enter the playlist: ')

videos=list(Playlist(plist))
i=videos[0]
video=YT(i)
strm=video.streams.filter(res="720p")
print(strm)
Run Code Online (Sandbox Code Playgroud)

从上面的代码我得到这样的错误

Traceback (most recent call last):
  File "D:\Practicals\Python\ML\youtube\temp.py", line 11, in <module>
    strm=video.streams.filter(res="720p")
         ^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pytube\__main__.py", line 296, in streams
    return StreamQuery(self.fmt_streams)
                       ^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pytube\__main__.py", line 176, in fmt_streams
    stream_manifest = extract.apply_descrambler(self.streaming_data)
                                                ^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pytube\__main__.py", line 161, in streaming_data
    return self.vid_info['streamingData']
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'streamingData'
Run Code Online (Sandbox Code Playgroud)

python python-3.x pytube

9
推荐指数
2
解决办法
1万
查看次数

使用pytube下载管视频时如何添加tqdm以显示进度条?

我正在学习pytube下载 Youtube 视频并尝试tqdm在它上面显示进度条,但它显示了各种错误,而且我无法理解当我下载视频pytube并显示进度条时发生了什么,这是我无法显示的原因加tqdm进去。

我写的代码pytube运行良好,这是代码:

from pytube import YouTube


url = str(input("Enter the video link: "))
yt = YouTube(url)
videos = yt.streams.filter(file_extension='mp4').all()

filename = yt.title


s = 1
for v in videos:
    print(str(s)+". "+str(v))
    s += 1

n = int(input("Enter the number of the video: "))
vid = videos[n-1]

vid.download("C:/Users/user/Downloads/")

print(yt.title,"\nHas been successfully downloaded")

Run Code Online (Sandbox Code Playgroud)

我需要tqdm添加到代码中才能显示进度条。

python youtube python-3.6 tqdm pytube

7
推荐指数
1
解决办法
698
查看次数

在 pytube3 中获取 youtube 视频的标题?

我正在尝试构建一个应用程序来使用pytube3在 python 中下载 YouTube 视频。
但我无法检索视频的标题。
这是我的代码:

from pytube import YouTube
yt = YouTube(link)
print(yt.title)
Run Code Online (Sandbox Code Playgroud)

无论链接是什么,我总是会返回标题而YouTube不是视频标题。有办法解决吗?

python pytube

7
推荐指数
1
解决办法
1万
查看次数

如何在 Pytube 中结合音频和视频?

我正在尝试编写一段代码,在 Python 3.6 上使用 Pytube 下载 YouTube 视频。但对于大多数视频,渐进式下载(同一文件中的音频和视频)格式最多只能提供 360p。所以我想把音频和视频文件分开下载然后合并起来。我能够下载音频和视频文件。如何将两个文件合并在一起?

python youtube python-3.x audio-video-sync pytube

6
推荐指数
2
解决办法
9573
查看次数