首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pafy Youtube转换视频时出错403

Pafy Youtube转换视频时出错403
EN

Stack Overflow用户
提问于 2022-02-05 18:27:01
回答 1查看 173关注 0票数 1

在使用pafy转换视频时,我得到了这个错误

代码语言:javascript
复制
GdataError at / Youtube Error 403: The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.

这是我的代码(views.py):

代码语言:javascript
复制
def download_video(request):
    global context
    form = DownloadForm(request.POST or None)
    if form.is_valid():
        video_url = form.cleaned_data.get("url")
        if 'm.' in video_url:
            video_url = video_url.replace(u'm.', u'')

        elif 'youtu.be' in video_url:
            video_id = video_url.split('/')[-1]
            video_url = 'https://www.youtube.com/watch?v=' + video_id

        if len(video_url.split("=")[-1]) != 11:
            return HttpResponse('Enter correct url.')

        video = pafy.new(video_url)
        stream = video.streams
        video_audio_streams = []
        for s in stream:
            video_audio_streams.append({
                'resolution': s.resolution,
                'extension': s.extension,
                'file_size': filesizeformat(s.get_filesize()),
                'video_url': s.url + "&title=" + video.title
            })

        stream_video = video.videostreams
        video_streams = []
        for s in stream_video:
            video_streams.append({
                'resolution': s.resolution,
                'extension': s.extension,
                'file_size': filesizeformat(s.get_filesize()),
                'video_url': s.url + "&title=" + video.title
            })

        stream_audio = video.audiostreams
        audio_streams = []
        for s in stream_audio:
            audio_streams.append({
                'resolution': s.resolution,
                'extension': s.extension,
                'file_size': filesizeformat(s.get_filesize()),
                'video_url': s.url + "&title=" + video.title
            })

        context = {
            'form': form,
            'title': video.title, 'streams': video_audio_streams,
            'description': video.description, 'likes': video.likes, 'thumb': video.bigthumbhd,
            'duration': video.duration, 'views': video.viewcount,
            'stream_video': video_streams, 'stream_audio': audio_streams
        }

        return render(request, 'home.html', context)

    return render(request, 'home.html', { 'form': form })

也许错误是从另一个文件触发的,我不得不从扩展名中更改后端的一些内容,但我不知道是什么。

我在用Django,Pafy,Pytz和Youtube-dl

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-05 18:52:55

您在API中做了太多的YouTube操作。如果你每天达到10.000点,你是有限的。在这里阅读:https://developers.google.com/youtube/v3/getting-started#quota

你可以在another StackOverflow Question上读到类似的东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71000916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档