You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB
Python

# Test Link https://www.youtube.com/watch?v=Lrj2Hq7xqQ8 -> Rick Roll
# %%
from __future__ import unicode_literals
import youtube_dl
import IPython.display as ipd
import librosa
class MyLogger(object):
def debug(self, msg):
pass
def warning(self, msg):
pass
def error(self, msg):
print(msg)
def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')
ydl_opts = {
'format': 'bestaudio/best',
#'outtmpl': '%(extractor_key)s/%(extractor)s-%(id)s-%(title)s.%(ext)s',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'wav',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=Lrj2Hq7xqQ8'])
# Lassie hat cookie fenster probleme und schafft es nicht durchzukommen
#print(lassie.fetch('http://www.youtube.com/watch?v=Lrj2Hq7xqQ8'))
#audio,sr = librosa.load(file)
#ipd.Audio(audio,rate = sr)
# %%