转换视频时 Pafy Youtube 错误 403
Pafy Youtube Error 403 when converting video
我在使用 pafy 转换视频时遇到此错误
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):
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
您在 YouTube
中做了太多 API
个动作。如果您每天达到 10.000 分,您将受到限制。在这里阅读:https://developers.google.com/youtube/v3/getting-started#quota
您可以在 another Whosebug Question 中阅读类似内容。
我在使用 pafy 转换视频时遇到此错误
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):
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
您在 YouTube
中做了太多 API
个动作。如果您每天达到 10.000 分,您将受到限制。在这里阅读:https://developers.google.com/youtube/v3/getting-started#quota
您可以在 another Whosebug Question 中阅读类似内容。