-
Notifications
You must be signed in to change notification settings - Fork 3
/
chromecastchecker.py
34 lines (31 loc) · 1.03 KB
/
chromecastchecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import time
import pychromecast
import os
import json
def check():
while True:
try:
services, browser = pychromecast.discovery.discover_chromecasts()
with open('./temp/chromecast.txt', 'w+') as f:
devnames = []
for service in services:
devnames.append(service[3])
for name in devnames:
f.writelines(name+'\n')
f.close()
pychromecast.discovery.stop_discovery(browser)
time.sleep(10)
except FileNotFoundError:
os.mkdir("cache")
with open('./temp/chromecast.txt', 'w+') as f:
devnames = []
for service in services:
devnames.append(service[3])
for name in devnames:
f.writelines(name+'\n')
f.close()
pychromecast.discovery.stop_discovery(browser)
time.sleep(10)
return
if __name__ == "__main__":
check()