Add Youtube integraion

- add python script to download youtube videos
- add new Media tab in UI to download youtube videos
- track PDS
- Script to play latest PDS, play from Media tab
- Automate latest PDS download
This commit is contained in:
2020-03-14 18:09:27 +02:00
parent 4e42f0ca06
commit 09b7a2ea3a
10 changed files with 148 additions and 4 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/python3.7
import sys
import youtube_dl
import os
youtube_url = sys.argv[1]
out_name = sys.argv[2] if len(sys.argv) > 2 else 'temp'
out_folder = sys.argv[3] if len(sys.argv) > 3 else ''
full_file_path = f"""~/.homeassistant/www/audio/youtube/{out_folder}{out_name}"""
ydl = youtube_dl.YoutubeDL({'format': 'bestaudio', 'outtmpl': full_file_path})
with ydl:
result = ydl.extract_info(youtube_url, download=True)
os.system(
f"""ffmpeg -i {full_file_path} -acodec libmp3lame {full_file_path}.mp3""")
os.system(f"""rm {full_file_path}""")