TypeError:videoResponsive()获得意外的关键字参数“width”

2024-05-21 16:50:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在试用yt iframe python库。 以下代码:

channel = yt.channel('https://www.youtube.com/user/ouramazingspace') # (Required)
width = '560' # (Optional)
height = '315' # (Optional)
responsive = True # (Optional)

# Fixed size iframes
iframes = yt.getFrames(channel, width=width, height=height)

# Responsive iframes
iframes = yt.getFrames(channel, responsive=responsive)

给出了错误:

Traceback (most recent call last):
  File "app.py", line 18, in <module>
    iframes = yt.getFrames(channel, responsive=responsive)
  File "D:\Level 4\PROJECT\PetProjects\SplitFrames\venv\lib\site-packages\yt_iframe\yt.py", line 134, in getFrames
    frame = videoResponsive(vid, width=width, height=height)
TypeError: videoResponsive() got an unexpected keyword argument 'width'

请帮我解决这个问题


Tags: 代码inpylinechannelwidthoptionalfile
1条回答
网友
1楼 · 发布于 2024-05-21 16:50:12

看起来库在库的第134行传递了无效的参数,所以这不容易解决,因为这不是您创建的bug

  File "D:\Level 4\PROJECT\PetProjects\SplitFrames\venv\lib\site-packages\yt_iframe\yt.py", line 134, in getFrames
    frame = videoResponsive(vid, width=width, height=height)
TypeError: videoResponsive() got an unexpected keyword argument 'width'

我只是查找了API文档,videoResponsive()似乎没有包含width关键字参数。这不是您的代码的问题,而是您正在使用的库/包的问题,因为这就是bug的来源。我建议尝试另一个库,或者在库的github页面上提出请求或提出问题,以便维护人员修复bug

# code example from https://pypi.org/project/yt-iframe/
url = 'https://www.youtube.com/watch?v=UzIQOQGKeyI' # (Required)
layout = 'singlecolumn' # (Optional)

video = yt.videoResponsive(url, layout=layout) # Get HTML

我在github上打开了一张罚单来修复bug here

相关问题 更多 >