-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (60 loc) · 2.16 KB
/
main.py
File metadata and controls
66 lines (60 loc) · 2.16 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
import twitch_integration
from selenium import webdriver
import time
import configparser
config = configparser.ConfigParser()
streamers = []
streamerslive = []
def get_streamers():
streamers = input("Names of streamers with commas seperating: ").replace(" ","").split(",")
times = input("Time in seconds to watch each streamer with commas seperating respective to the streamer: ").replace(" ","").split(",")
return streamers, times
def checklive(streamers):
results = []
isLive = twitch_integration.get_current_online_streams(streamers)
for i in range(len(streamers)):
try:
if isLive[i][1] == "live":
results.append(streamers[i])
except:
none = "no"
return results
def start_watching(streamers, streamerslive, username, t):
config.read("config.ini")
profile = config["Chrome"]["Profile"]
print(f"Started watching {username}!")
URL = f"https://www.twitch.tv/{username}"
options = webdriver.ChromeOptions()
options.headless = config["Chrome"]["Headless"]
options.add_argument(f"user-data-dir={profile}")
driver = webdriver.Chrome(executable_path=r"chromedriver.exe", options=options)
driver.get(URL);
time.sleep(60+int(t))
streamers.remove(username)
streamerslive.remove(username)
driver.close()
time.sleep(5)
return streamers, streamerslive
def main():
print('''
_____ ____ _
| __ \ | _ \ | |
| | | |_ __ ___ _ __ | |_) | ___ | |_
| | | | '__/ _ \| '_ \| _ < / _ \| __|
| |__| | | | (_) | |_) | |_) | (_) | |_
|_____/|_| \___/| .__/|____/ \___/ \__|
| |
|_| By: Alex Knusel
''')
streamers, times = get_streamers()
while True:
if len(streamers) == 0:
break
streamerslive = checklive(streamers)
try:
streamers, streamerslive = start_watching(streamers, streamerslive, streamerslive[0], times[0])
except IndexError:
print("Nobody is live right now!\nStreamers Left: {}".format(", ".join(streamers)))
time.sleep(60)
if __name__ == "__main__":
main()