Code Monkey home page Code Monkey logo

Comments (7)

jerkovicl avatar jerkovicl commented on June 29, 2024

would be nice feature yep!

from soccer-cli.

ueg1990 avatar ueg1990 commented on June 29, 2024

it is a good feature but its temporary because it happens once every 4 years...but based on the API, there is a key that maps to the Euros ("EC") and I am assuming they will have something for the World Cup and Copa America too. So if there is a way to integrate it such it we can use them in the future international tournaments then we should definitely have it 😄 👍

from soccer-cli.

DevNils avatar DevNils commented on June 29, 2024

Hey Folks,
if you can't wait, here is a simple and dumb script that shows the current EURO 2016 results:

import json
import urllib2
from datetime import datetime
from dateutil import tz

req = urllib2.Request('http://api.football-data.org/v1/soccerseasons/424/fixtures')
req.add_header('X-Response-Control', 'minified')
response = urllib2.urlopen(req).read()
jsonData = json.loads(response)

from_zone = tz.tzutc()
to_zone = tz.tzlocal()

for fixture in jsonData['fixtures']:
    resultHome = fixture['result']['goalsHomeTeam']
    resultAway = fixture['result']['goalsAwayTeam']
    date = datetime.strptime(fixture['date'], '%Y-%m-%dT%H:%M:%SZ')
    date = date.replace(tzinfo=from_zone)
    date = date.astimezone(to_zone)

    if fixture['status'] == 'IN_PLAY':
        print('\n')

    print('{}  {}\t{}:{}  {} - {}'.format(
        date.strftime('%Y-%m-%d %H:%M'),
        fixture['status'] if not fixture['status'] == 'TIMED' else fixture['status'] + '\t',
        resultHome if not resultHome is None else '-',
        resultAway if not resultAway is None else '-',
        fixture['homeTeamName'],
        fixture['awayTeamName'],
    ))

    if fixture['status'] == 'IN_PLAY':
        print('\n')

Cheers

Nils

from soccer-cli.

jerkovicl avatar jerkovicl commented on June 29, 2024

@DevNils on python 3.5.1 after i fixed imports gives me error :
TypeError: the JSON object must be str, not 'bytes

from soccer-cli.

thurask avatar thurask commented on June 29, 2024

@jerkovicl Or just replace stdlib with requests:

import json
import requests
from datetime import datetime
from dateutil import tz

headers = {'X-Response-Control': 'minified'}
req = requests.get('http://api.football-data.org/v1/soccerseasons/424/fixtures', headers=headers)
jsonData = req.json()

etc...

Works here on 3.5.1:
europy

from soccer-cli.

jerkovicl avatar jerkovicl commented on June 29, 2024

@thurask thx man, it works;)

from soccer-cli.

DevNils avatar DevNils commented on June 29, 2024

@thurask thank you for this fix.

from soccer-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.