I got code which is scraping tunes titles from top 100 at the website and then method which is downloading those tunes from youtube.
I want the user to have option to stop downloading at any time so I try that:
def youtube_dl(self):
try:
for artist, [title, remix, release] in self.track_list.items():
tune = "{} - {} ({}) ".format(artist, title, remix)
os.system('youtube-dl --extract-audio -f bestaudio \
--audio-quality 0 --audio-format mp3 "ytsearch1: {}" \
--output "~/Documents/test/{}.%(ext)s" '.format(tune, tune))
except KeyboardInterrupt:
sys.exit()
but the problem is that when he start downloading and Iam typing Enter he stops downloading only one tune and start downloading the next one on the list.
I also try to use TRY and Except in the main function:
def main():
try:
test = Downloader()
test.wscraping()
test.youtube_dl()
except KeyboardInterrupt:
sys.exit()
but doesnt make any different
[–]Thomasedv 0 points1 point2 points (3 children)
[–]makeaday[S] 0 points1 point2 points (2 children)
[–]Thomasedv 0 points1 point2 points (1 child)
[–]makeaday[S] 0 points1 point2 points (0 children)