Issue
I'm getting this error when converting a video using 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>.
This is my code (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 })
Maybe the error is triggered from another file and I have to change something in the backend from the extensions but I cant figure out what.
I'm using Django, Pafy, Pytz and Youtube-dl
Solution
You have done too many API
actions in YouTube
. If you reach 10.000 points per day you are limited. Read about it here: https://developers.google.com/youtube/v3/getting-started#quota
And you can read about similar things in another StackOverflow Question.
Answered By - NixonSparrow
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.