项目作者: gwelt

项目描述 :
generate standings using openligadb-data (node)
高级语言: JavaScript
项目地址: git://github.com/gwelt/liga.git
创建时间: 2017-09-10T14:55:09Z
项目社区:https://github.com/gwelt/liga

开源协议:

下载


liga

generate standings using openligadb-data (node)
This will launch a HTTP-Server with a minimal user-interface that serves the standings (“Bundesliga-Tabelle”) and a list of matches for the active matchday and the following one.

Why?

I want to print the standings of german Fußball-Bundesliga on a thermal-printer.
This is the result:
liga

How?

I’ll use an existing service on a Raspberry Pi that will launch a HTTP-request, get the pre-formatted data and send it to the thermal-printer. To create my own thermal-printer-table-style, the data needs to be available in raw format first. I decided to get the matches-data from openligadb.de and do the math on my own.

  • Create a Team-object for each Bundesliga-Team from teams-JSON. (Edited data from openligadb to fit my needs.)
  • Parse match-data from openligadb and update Team-objects with current scores (won, draw, lost, goals_shot, goals_got).
  • Sort teams by scores.
  • Pre-format the data to fit the thermal-printer (fake columns by indenting blanks at a max-width of 32 characters).
  • Create a HTTP-express-server to proxy and serve the data.
  • Update data on demand (reload match-data from openligadb).
  • (additional) Parse match-data to get matches of the current matchday and the following one.

Usage

Install and start the server.

  1. git clone http://github.com/gwelt/liga
  2. cd liga
  3. npm install
  4. npm start

http://localhost:3004 to call the HTTP-interface.
http://localhost:3004/bl1 to get the standings and a list of matches.
http://localhost:3004/bl1/json to get the standings and all matches data as JSON-object.
http://localhost:3004/bl1/print/tabelle to get the pre-formatted standings.
http://localhost:3004/bl1/print/spiele to get the pre-formatted list of matches for the active matchday and the following one.
http://localhost:3004/bl1/update to update the server-cache.

Example

http://localhost:3004/bl1

  1. 1 Dortmund 3 5:0 +5 7
  2. 2 Hoffenheim 3 5:2 +3 7
  3. 3 Hannover 3 3:1 +2 7
  4. 4 RB Leipzig 3 6:3 +3 6
  5. 5 Schalke 3 5:2 +3 6
  6. 6 Bayern 3 5:3 +2 6
  7. 7 Hamburg 3 4:3 +1 6
  8. 8 Augsburg 3 5:3 +2 4
  9. 9 Hertha BSC 3 3:3 0 4
  10. M'gladbach 3 3:3 0 4
  11. 11 Frankfurt 3 1:1 0 4
  12. 12 Wolfsburg 3 2:4 -2 4
  13. 13 Mainz 05 3 3:3 0 3
  14. 14 Stuttgart 3 2:5 -3 3
  15. 15 Freiburg 3 1:4 -3 2
  16. 16 Werder 3 1:4 -3 1
  17. 17 Leverkusen 3 4:8 -4 1
  18. 18 Koeln 3 1:7 -6 0
  19. 3. Spieltag
  20. Hamburg RB Leipzig 0:2
  21. Freiburg Dortmund 0:0
  22. M'gladbach Frankfurt 0:1
  23. Augsburg Koeln 3:0
  24. Mainz 05 Leverkusen 3:1
  25. Wolfsburg Hannover 1:1
  26. Hoffenheim Bayern 2:0
  27. Hertha BSC Werder 1:1
  28. Schalke Stuttgart 3:1
  29. 4. Spieltag
  30. Hannover Hamburg FR 20:30
  31. Bayern Mainz 05 SA 15:30
  32. Werder Schalke SA 15:30
  33. Frankfurt Augsburg SA 15:30
  34. Stuttgart Wolfsburg SA 15:30
  35. RB Leipzig M'gladbach SA 18:30
  36. Hoffenheim Hertha BSC SO 13:30
  37. Leverkusen Freiburg SO 15:30
  38. Dortmund Koeln SO 18:00