From 25cf21967b28f427b1a1232b4652b58f13a03330 Mon Sep 17 00:00:00 2001 From: DanielXYZ2000 Date: Wed, 17 Oct 2018 23:50:32 +0200 Subject: [PATCH 1/2] simple youtube downloader example --- pafy_example/YoutubeDownloaderMegaSimple.py | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 pafy_example/YoutubeDownloaderMegaSimple.py diff --git a/pafy_example/YoutubeDownloaderMegaSimple.py b/pafy_example/YoutubeDownloaderMegaSimple.py new file mode 100644 index 0000000..df1c51e --- /dev/null +++ b/pafy_example/YoutubeDownloaderMegaSimple.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +""" +Created on Sun Oct 14 19:16:31 2018 + +Links: +https://github.com/amitsagtani97/Python-Scripts/blob/6d5964d0134e4b6994f7f67459d4c6c81c73770e/Youtube-Downloader/down.py + +https://pythonhosted.org/pafy/#stream-lists + +https://github.com/mps-youtube/pafy +https://www.geeksforgeeks.org/youtube-mediaaudio-download-using-python-pafy/ + +""" + +#%% +import pafy +#%% +plurl='https://www.youtube.com/playlist?list=PL21F4788EBF186DC0' # Pumuckl +plurl='https://www.youtube.com/playlist?list=PLQrsocOZ_VCmc6WE4QHNpG-PTN4TgS6-7' # Eisbär Affe & Co (todo) +playlist = pafy.get_playlist(plurl) +#%% +for i in range(22,len(playlist['items'])): + #%% + pstream=playlist['items'][i]['pafy'].getbest() + pstream.download(filepath="C:/tmp") + +#%% +print("ready") + +#%% Musik Download +plurl='https://www.youtube.com/playlist?list=PLw-VjHDlEOgvtnnnqWlTqByAtC7tXBg6D' +folder='YoutubeMusic' +plurl='https://www.youtube.com/watch?v=9xjI5Zf6bl8&list=PLC01DA09095BEED88' +folder='Parkour' +# todo create folder automatically +playlist = pafy.get_playlist(plurl) +#% +for i in range(0,len(playlist['items'])): + #% + p1=playlist['items'][i]['pafy'] + #% + p1.getbestaudio().download(filepath="C:/tmp/"+folder) + +#% +print("ready") \ No newline at end of file From 05b5c7d32fbf6e6123b9bebcb9ffb609e8e8f2bf Mon Sep 17 00:00:00 2001 From: DanielXYZ2000 Date: Wed, 17 Oct 2018 23:56:30 +0200 Subject: [PATCH 2/2] create folder --- pafy_example/YoutubeDownloaderMegaSimple.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pafy_example/YoutubeDownloaderMegaSimple.py b/pafy_example/YoutubeDownloaderMegaSimple.py index df1c51e..d97e9a9 100644 --- a/pafy_example/YoutubeDownloaderMegaSimple.py +++ b/pafy_example/YoutubeDownloaderMegaSimple.py @@ -14,6 +14,7 @@ #%% import pafy +import os #%% plurl='https://www.youtube.com/playlist?list=PL21F4788EBF186DC0' # Pumuckl plurl='https://www.youtube.com/playlist?list=PLQrsocOZ_VCmc6WE4QHNpG-PTN4TgS6-7' # Eisbär Affe & Co (todo) @@ -29,17 +30,19 @@ #%% Musik Download plurl='https://www.youtube.com/playlist?list=PLw-VjHDlEOgvtnnnqWlTqByAtC7tXBg6D' -folder='YoutubeMusic' -plurl='https://www.youtube.com/watch?v=9xjI5Zf6bl8&list=PLC01DA09095BEED88' -folder='Parkour' -# todo create folder automatically +folder='YoutubeMusic1' +#plurl='https://www.youtube.com/watch?v=9xjI5Zf6bl8&list=PLC01DA09095BEED88' +#folder='Parkour' +newpath = 'C:/tmp/'+folder +if not os.path.exists(newpath): + os.makedirs(newpath) playlist = pafy.get_playlist(plurl) #% for i in range(0,len(playlist['items'])): #% p1=playlist['items'][i]['pafy'] #% - p1.getbestaudio().download(filepath="C:/tmp/"+folder) + p1.getbestaudio().download(filepath=newpath) #% print("ready") \ No newline at end of file