add youtube

This commit is contained in:
qvalentin 2022-01-01 16:49:57 +01:00
parent 80ce250dd7
commit f7ed6117e4
2 changed files with 29 additions and 1 deletions

View File

@ -14,4 +14,3 @@ mc = cast.media_controller
# see https://github.com/mediathekview/zapp/blob/0df9ea4eccc3ddc9ca9d344f7d5c1916e19696e0/app/src/main/res/raw/channels.json # see https://github.com/mediathekview/zapp/blob/0df9ea4eccc3ddc9ca9d344f7d5c1916e19696e0/app/src/main/res/raw/channels.json
mc.play_media('https://mcdn.daserste.de/daserste/de/master.m3u8', 'application/vnd.apple.mpegurl') mc.play_media('https://mcdn.daserste.de/daserste/de/master.m3u8', 'application/vnd.apple.mpegurl')
mc.block_until_active() mc.block_until_active()
print(mc.status)

29
youtube.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python3
import sys
import pychromecast
from pychromecast.controllers.youtube import YouTubeController
CC_IP = '192.168.178.22'
playing = True
video_id = sys.argv[1]
cast = pychromecast.Chromecast(CC_IP)
cast.wait()
yt = YouTubeController()
cast.register_handler(yt)
yt.play_video(video_id)
mc = cast.media_controller
for line in sys.stdin:
if playing:
mc.pause()
else:
mc.play()
playing = not playing