Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bombsimon/hltv-python
📺 HLTV live score implementation with Socket.IO
https://github.com/bombsimon/hltv-python
counter-strike counter-strike-global-offensive csgo hacktoberfest hltv livescore scorebot
Last synced: about 2 months ago
JSON representation
📺 HLTV live score implementation with Socket.IO
- Host: GitHub
- URL: https://github.com/bombsimon/hltv-python
- Owner: bombsimon
- License: mit
- Created: 2019-09-13T00:30:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-09T23:04:55.000Z (4 months ago)
- Last Synced: 2024-10-20T21:41:07.713Z (2 months ago)
- Topics: counter-strike, counter-strike-global-offensive, csgo, hacktoberfest, hltv, livescore, scorebot
- Language: Python
- Homepage:
- Size: 392 KB
- Stars: 15
- Watchers: 5
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HLTV Livescore
This is a HLTV livescore implementation in Python. It feels super weird that I
don't find any implementations for this but I might be bad at looking. The two
JavaScript versions I found helped me understand and get inspiration.Borrowed with pride from:
- [Nols1000/hltv-scorebot](https://github.com/Nols1000/hltv-scorebot)
- [andrewda/hltv-livescore](https://github.com/andrewda/hltv-livescore) (wraps
above linked)
- [osebrwn/csgo-livescore](https://github.com/josebrwn/csgo-livescore) (wraps
above linked)Might integrate with other Python libraries in the future, such as
- [SocksPls/hltv-api](https://github.com/SocksPls/hltv-api)
## Documentation
General documentation about the Socket.IO streams can be found in
[DOCUMENTATION.md](DOCUMENTATION.md)## Live scoring
So HLTV uses [Socket.IO](https://socket.io/) to stream the data they get from
Valve and ESL (I think?). This data is pushed on a socket. See
[DOCUMENTATION](DOCUMENTATION.md) for server information.I actually have a really (really) hard time finding any documentation at all
regarding this socket. Is it official? Is it documented? How's it rate limited?
What events are pushed, how and when, and with what data? Because of this I've
tried to document my findings in [DOCUMENTATION.md](DOCUMENTATION.md).## This implementation
Luckily there's a great library named
[python-socketio](https://python-socketio.readthedocs.io/en/latest/index.html)
which makes it easy for me to read from the socket. All I need to do after
connecting is to parse the stream. ✌🏼## Usage
```python
import asyncio
from scorebot import Livescoreasync def on_kill(frag):
print("{} killed {}".format(frag.killer.name, frag.victim.name))async def main():
ls = Livescore(123456)
ls.on(ls.EVENT_KILL, on_kill)socket = await ls.socket()
await socket.wait()if __name__ == "__main__":
asyncio.run(main())
```See [examples](examples/) folder for an implementation creating a kill feed.