-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlivescore.py
executable file
·50 lines (38 loc) · 1.54 KB
/
livescore.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from lib.lsweb import get_games, get_table, is_connected
from lib.lsprint import display_games, display_table, clear_screen
from lib.cli import args
from lib.urls import details, base_url
import time
def main():
b_score = bool(args.score)
b_table = bool(args.table)
prev_data = {}
while True:
try:
for cname in args.competition:
if is_connected('www.livescores.com'):
event_type = 'competition'
title = details.get(event_type).get(cname).get('title')
if b_score:
games = get_games(cname, event_type)
if (games != prev_data):
print(f'displaying scores for {title}')
clear_screen()
display_games(games, title, prev_data)
prev_data = games
if b_table:
table = get_table(cname, event_type)
print(f'displaying table for {title}')
clear_screen()
display_table(table, title)
else:
print(f"couldn't connect to the livescore website. check your internet connection.")
time.sleep(2)
if (not b_score):
break
except KeyboardInterrupt:
break
if __name__ == '__main__':
main()