I want to pass the link user entered on a form to the downloader method.
from django.shortcuts import render
import pytube
from .forms import VideoDownloadForm
# Create your views here.
def details(request):
if request.method == 'POST':
form = VideoDownloadForm(request.POST, request.FILES)
if form.is_valid():
f = form.cleaned_data['Url']
yt = pytube.YouTube(f)
# videos = yt.streams.filter(progressive=True, type='video', subtype='mp4').order_by('resolution').desc().first()
thumb = yt.thumbnail_url
title = yt.title
return render(request, 'ytdownloader/details.html', { 'title': title, 'thumbnail': thumb})
downloader(yt)
else:
form = VideoDownloadForm()
return render(request, 'ytdownloader/front.html', {'form': form})
def downloader(request, yt):
videos = yt.streams.filter(progressive=True, type='video', subtype='mp4').order_by('resolution').desc().first()
videos.download('C:\\Users\\user\\Downloads')
return render(request, 'ytdownloader/details.html')
Error:
*Exception Type :TypeError
Exception Value :downloader() missing 1 required positional argument: 'yt'*