-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume.py
More file actions
79 lines (63 loc) · 2.08 KB
/
volume.py
File metadata and controls
79 lines (63 loc) · 2.08 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import pychromecast
import sys
import os
from time import sleep
try:
import readline
except ImportError:
import pyreadline as readline
hLine = "=" * 80
header = ""
about = "The One-Stop Shop for Annoying Your Fellow Google Cast Users"
with open("header", "rb") as headFile:
header = headFile.read().decode("UTF-16")
def cls():
os.system('cls' if os.name == 'nt' else 'clear')
def printHeader():
cls()
print(hLine)
[print(line.center(80)) for line in header.splitlines()]
print(about.center(80))
print(hLine,"\n")
def completer(text, state):
options = [cmd for cmd in [cc.device.friendly_name for cc in l] if cmd.startswith(text)]
if state < len(options):
return options[state]
else:
return None
readline.parse_and_bind("tab: complete")
readline.set_completer(completer)
printHeader()
print("Performing Discovery for Cast Devices...")
l = (pychromecast.get_chromecasts())
# It's pretty useless to run without any targets...so don't!
if len(l[0]) == 0:
print("[ fail ] No Cast Devices Found")
exit(0)
print("Discovered {} Cast Devices:\n".format(len(l)))
while(True):
# PRINT TARGET LIST
print("-"*80)
sortedDevices = sorted([cc.device.friendly_name for cc in l])
[print("{:<30}{:<30}{:<}".format(a,b,c)) for a,b,c in zip(sortedDevices[::3], sortedDevices[1::3], sortedDevices[2::3])]
print("_"*80 + "\n")
# TARGET PROMPT
target = input("selectTarget> ")
print("Connecting to {}...".format(target))
# ATTEMPT TO CONNECT
try:
cast = next(cc for cc in l if cc.device.friendly_name == target)
cast.wait()
print("Connected to {}.".format(target))
num = input("attackRange> ")
print("Attacking with range {}...".format(num))
for i in range(0, int(num)):
i = i % 10
i = i / 10
cast.set_volume(i)
sleep(.4)
print("Attack Complete.")
except Exception as e:
print("[ fail ] Could not connect to {}. Exception: {}".format(target,str(e)))
input("\n[ENTER] To Continue...")
printHeader()