From 984d18104df0ccfd98f9a4b0e93bc380a1737010 Mon Sep 17 00:00:00 2001 From: Omair Ahmed Date: Sat, 2 Jul 2022 11:51:55 -0400 Subject: [PATCH 1/2] Update pychromecast version --- requirements.txt | 2 +- www/lib/chromecast.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index b8fa26f..7d4d1ec 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Flask adhan geopy -PyChromecast==6.0.0 +PyChromecast==7.5.1 python-crontab croniter configparser diff --git a/www/lib/chromecast.py b/www/lib/chromecast.py index 8d76bd5..7a6a9ce 100755 --- a/www/lib/chromecast.py +++ b/www/lib/chromecast.py @@ -44,8 +44,8 @@ def play(self, deviceName, media): def chromecastPlay(self, deviceName, mediaUrl): url = mediaUrl - chromecasts = pychromecast.get_chromecasts() - cast = next(cc for cc in chromecasts if cc.device.friendly_name == deviceName) + chromecasts, browser = pychromecast.get_listed_chromecasts(friendly_names=[deviceName]) + cast = chromecasts[0] cast.wait() #cast.quit_app() mc = cast.media_controller From 0f4b67a2a5b6458238e0cc9bf6d25c1399dc29f3 Mon Sep 17 00:00:00 2001 From: Omair Ahmed Date: Sun, 3 Jul 2022 10:23:15 -0400 Subject: [PATCH 2/2] Fix YouTube cast too --- www/lib/chromecast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/lib/chromecast.py b/www/lib/chromecast.py index 7a6a9ce..0a8ff23 100755 --- a/www/lib/chromecast.py +++ b/www/lib/chromecast.py @@ -69,8 +69,8 @@ def chromecastPlayYoutube(self, deviceName, mediaUrl): VIDEO_ID = query["v"][0] print(VIDEO_ID) - chromecasts = pychromecast.get_chromecasts() - cast = next(cc for cc in chromecasts if cc.device.friendly_name == deviceName) + chromecasts, browser = pychromecast.get_listed_chromecasts(friendly_names=[deviceName]) + cast = chromecasts[0] cast.wait() yt = YouTubeController() cast.register_handler(yt)