Skip to content

Commit

Permalink
soccer plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-199 committed Sep 18, 2024
1 parent 19b645b commit 5454314
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jarviscli/plugins/soccer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import requests
from datetime import datetime as dt
from plugin import plugin, require


@require(network=True)
@plugin("soccer")
class Soccer:
API_KEY = None
BASE_URL = "http://api.football-data.org/v4/"
Expand All @@ -16,6 +19,7 @@ def __call__(self, jarvis, s):
self.get_competitions()
while True:
competition_id = input("Enter ID to view matches for a competition, \\table to view competitions, \\key to re-enter API key, or \\exit to exit: ")
print()
if competition_id == '\\table':
self.get_competitions()
elif competition_id == '\\exit':
Expand All @@ -24,9 +28,9 @@ def __call__(self, jarvis, s):
self.API_KEY = input('Enter an API key by registering at football-data.org/client/register: ')
sample_request = requests.get(self.BASE_URL + 'competitions/2013/matches', headers={'X-Auth-Token': self.API_KEY})
if sample_request.status_code == 200:
print('API Key is validated')
print('API Key is validated\n')
else:
print('Invalid API key')
print('Invalid API key\n')
else:
try:
self.get_matches(competition_id)
Expand Down

0 comments on commit 5454314

Please sign in to comment.