Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to build a frontend for my youtube video downloader program?

I want to build a basic frontend for the below program, so that when users enter the app they will get the same output as in a python interpreter.
here is the python code

from pytube import YouTube

def Download(link):
  youtubeObject = YouTube(link)
  youtubeObject = youtubeObject.streams.get_highest_resolution()
  try:
      youtubeObject.download()
  except:
    print("There has been an error in downloading your youtube video")
  print("This download has completed! Yahooooo!")

link = input("Put your youtube link here!! URL: ")
Download(link)

I am expecting to build a small app where users can enter their video link and download the video. I just want to learn how to integrate it with a good looking user interface.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

  1. A web browser cannot interpret python, so your python code will live on an another computer.
  2. That another computer is a server, and to communicate with the server, you’ll need an API route. e.g (/process)
  3. The frontend will hit the API with the link as a parameter. (let’s say) (/process?link=<youtube-link>)
  4. The logic for handling that API will be written on the server. You can choose any language for that. Since you’re familiar with Python already, use Flask or Fast API.
  5. Once you host your server code you’re ready for communicating with the front-end with simple Fetch API.

References:

  1. https://flask.palletsprojects.com/en/2.2.x/
  2. https://fastapi.tiangolo.com/
  3. https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading