gigobyte / HLTV

The unofficial HLTV Node.js API
MIT License
397 stars 107 forks source link

Who we can get all the matches attached for an event? #124

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi,

As always, excellent work! but I found a bit tricky to retrieve all the matches linked to an event.

Ideally, I would like to have X events, and have all the matches attached to it. Some of them would be upgoing matches, live matches, or past matches.

I do not find the way to retrieve them easily. What i'm doing is using getMatchesStats, using the date interval (using the start/end date from the event), then filtering all the results by the eventId, and from the result, using getMatchMapStats to get the matchPageID, which is the one I need to finally use getMatch.

Is there any easier way? I mean, would be fantastic if we could just access the events by the eventId, so you can use getMatches({eventId}), for example.

Thanks in advance! Regards.

gigobyte commented 5 years ago

This feature is related to https://github.com/gigobyte/HLTV/issues/27, which I haven't got into implementing.

I'm spending my free time on other projects and currently I'm only reviewing PRs and providing bugfixes, I don't know when I'll be able to add a completely new endpoint. If you'd like to give it a try I won't mind reviewing it and including it in the library, the code is dead simple, just peek into the source of any of the endpoints, it's basically jQuery. Also I'm not very picky on the quality of the code since the goal is to provide you folks with as much functionality as possible, most people use this library for personal projects and playing around so things like stability and correctness are not the ultimate goal here.

ghost commented 5 years ago

Yeah no problem! We appreciate so much your current work!

I am trying to find out how to do it, I think getMatches could be added a possible eventId, because the matches (upcoming) can be found by /matches?eventid so... I'll try.

ghost commented 5 years ago

How could I add your library manually so I can change the source code?

I am trying to copy/paste this repo and just use the import HLTV from "../../htlv" but gives me an error... maybe im getting this wrong.

gigobyte commented 5 years ago

You can fork this repository and clone it to your machine just like any other repository. I usually experiment and run library code in the playground.ts file. If you run yarn start it will run, you can also manually start it with ts-node src/playground.ts.

My suggestion for the API is to a new "getEventStats" endpoint that parses the following pages:

https://www.hltv.org/matches?event=XXX`
https://www.hltv.org/results?event=XXX
https://www.hltv.org/stats?event=XXX

I'd like to keep getMatches only for the matches on the home page.

gigobyte commented 5 years ago

I'll close this as it's related to https://github.com/gigobyte/HLTV/issues/27