From a78c5bf7c3ffe4df72c38efb4c59e3b4a8ff8714 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 5 Jun 2022 12:09:33 +0200 Subject: [PATCH] add shortcuts --- #youtube.py# | 28 ++++++++++++++++++++++++++++ .shortcuts/ard.sh | 2 ++ .shortcuts/ld-ka.sh | 2 ++ custom_url.py | 17 +++++++++++++++++ termux-url-opener | 2 +- 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 #youtube.py# create mode 100755 .shortcuts/ard.sh create mode 100755 .shortcuts/ld-ka.sh create mode 100755 custom_url.py diff --git a/#youtube.py# b/#youtube.py# new file mode 100755 index 0000000..cd3846c --- /dev/null +++ b/#youtube.py# @@ -0,0 +1,28 @@ +#!/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 diff --git a/.shortcuts/ard.sh b/.shortcuts/ard.sh new file mode 100755 index 0000000..ae5c421 --- /dev/null +++ b/.shortcuts/ard.sh @@ -0,0 +1,2 @@ +python $HOME/chromeCast-py/das_erste.py + diff --git a/.shortcuts/ld-ka.sh b/.shortcuts/ld-ka.sh new file mode 100755 index 0000000..00831dc --- /dev/null +++ b/.shortcuts/ld-ka.sh @@ -0,0 +1,2 @@ +bash $HOME/db/ld-ka.sh + diff --git a/custom_url.py b/custom_url.py new file mode 100755 index 0000000..77b2b42 --- /dev/null +++ b/custom_url.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import sys +import pychromecast + + +CC_IP = '192.168.178.22' + +cast = pychromecast.Chromecast(CC_IP) +cast.wait() + + +mc = cast.media_controller + +# see https://github.com/mediathekview/zapp/blob/0df9ea4eccc3ddc9ca9d344f7d5c1916e19696e0/app/src/main/res/raw/channels.json +mc.play_media(sys.argv[1], 'application/vnd.apple.mpegurl') +mc.block_until_active() diff --git a/termux-url-opener b/termux-url-opener index 55b0b4f..14b7edd 100755 --- a/termux-url-opener +++ b/termux-url-opener @@ -6,7 +6,7 @@ echo $url if [[ "$url" =~ "youtube" ]]; then video_id=$(echo $url | sed 's#https://www.youtube.com/watch?v=##g') echo $video_id - youtube.py $video_id + python $HOME/chromeCast-py/youtube.py $video_id exit 0 fi