I'm using tkinter and youtube-dl under python
def dl(lk,fl): # link / file location
opts=['-o', fl+'/%(title)s-%(id)s.%(ext)s', '--playlist-end', '20', '--extract-audio', '--audio- format', 'mp3', '--audio-quality', '9', '--write-thumbnail', lk]
youtube_dl.main(opts)
return "Successful download"
This is the basic function which using the library, nothing extraordinary.
I call it from tkinter, so when I run it, the download start and finish. After, it close my tkinter windows.
Here, the function which call the first function in a tkinter class.
def dlv(self):
self.url = self.iurl.get()
if not self.url:
self.msg = "Error : no url"
elif not urlregex.match(self.url):
self.msg = "Error : invalid url"
else:
self.msg = dl(self.url,filel)
self.Com()
I try to stop by calling some functions as input or raw input. I also looked for option from the youtube dl librarie.
Nothing has work well.
Thanks
I'm not familiar with
youtube_dl
. but, i think it callssys.exit
at the end.Trysubprocess.Popen
instead.Something like,
Note that i didn't test this code.also this will hang the main tkinter window.you might wanna call this in a separate thread/process.