Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple youtube downloader example #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions pafy_example/YoutubeDownloaderMegaSimple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- 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
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)
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='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=newpath)

#%
print("ready")