pythondownloadpafy

Setting a certain location when using pafy


This is my code:

import pafy 

url = "youtube_url_here"
vid = pafy.new(url)
reso = vid.getbest()
reso.download()

Could anyone tell me how to set a location to save the video in instead of the working directory?, also how to make the program ask me what resolution I want to download ?


Solution

  • If you read the documentation of pafy you will find that you can pass a filename parameter to the download() function:

    reso.download(filepath="/tmp/video." + reso.extension)
    

    This is a Linux path though, so you might adjust it to use a Windows file path instead.