architv / soccer-cli

:soccer: Football scores for hackers. :computer: A command line interface for all the football scores.
MIT License
1.09k stars 220 forks source link

Convert leagues to JSON, add league lookup #86

Open thurask opened 8 years ago

thurask commented 8 years ago

Continuing from #83, replace the league*.py files with leagues.json, which is similar in structure to teams.json.

...
      "properties":{  
        "cl":[  
          1,
          3
        ],
        "el":[  
          4,
          4
        ],
        "rl":[  
          19,
          20
        ]
      },
      "name":"Ligue 1",
      "code":"FL",
      "id":396
    },
    {  
      "properties":{  
        "cl":[  
          1,
          2
        ],
        "el":[  
          3,
          6
        ],
        "rl":[  
          21,
          24
        ]
      },
      "name":"League One",
      "code":"EL1",
      "id":425
    },
...

Rewrite main.py and writers.py to accomodate.

As well, add league codes to the --list arg, like so: soccer1

Lastly, extend --lookup arg to work for leagues as well, in the spirit of #85.

$ soccer --league BL2 --lookup
2. Bundesliga
thurask commented 8 years ago

Okay, found some bugs with the initial commit. Had to move JSON loading into jsonhandler.py, then have main.py and writers.py work from there. Otherwise we'd get cyclical imports and other bad stuff.

As a result, this works not just with python main.py, but also regular old soccer.