Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions soccer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import requests
import sys
import json
import time as python_time

from soccer import leagueids
from soccer.exceptions import IncorrectParametersException, APIErrorException
Expand Down Expand Up @@ -226,6 +227,7 @@ def list_team_codes():
help="List all valid team code/team name pairs.")
@click.option('--live', is_flag=True,
help="Shows live scores from various leagues.")
@click.option('--watch', '-w', default=None, help="Refreshes screen after a given time interval in sec (in seconds)")
@click.option('--use12hour', is_flag=True, default=False,
help="Displays the time using 12 hour format instead of 24 (default).")
@click.option('--standings', is_flag=True,
Expand All @@ -250,7 +252,7 @@ def list_team_codes():
help='Output in JSON format.')
@click.option('-o', '--output-file', default=None,
help="Save output to a file (only if csv or json option is provided).")
def main(league, time, standings, team, live, use12hour, players, output_format,
def main(league, time, standings, team, live, watch, use12hour, players, output_format,
output_file, upcoming, lookup, listcodes, apikey):
"""
A CLI for live and past football scores from various football leagues.
Expand Down Expand Up @@ -289,6 +291,13 @@ def main(league, time, standings, team, live, use12hour, players, output_format,
get_live_scores(writer, use12hour)
return

if watch:
while True:
get_live_scores(writer, use12hour)
python_time.sleep(int(watch))
print(chr(27) + "[2J")
return

if standings:
if not league:
raise IncorrectParametersException('Please specify a league. '
Expand All @@ -312,4 +321,4 @@ def main(league, time, standings, team, live, use12hour, players, output_format,
click.secho(e.message, fg="red", bold=True)

if __name__ == '__main__':
main()
main()