web icon indicating copy to clipboard operation
web copied to clipboard

Implement live games page (with pro players)

Open mdfwn opened this issue 8 years ago • 29 comments

Hello, I'm the author of this thread: https://www.reddit.com/r/DotA2/comments/6xmvfq/i_built_my_own_version_of_dota2tvprocom_because/

tl;dr: dota2tvpro.com tracks high MMR games and games of dota 2 personalities, but the site is always down. I built my own logger using python (dota2api lib and Flask) but I don't know where to host it.

I just thought about collaborating with opendota. Do you think this could be a possible feature for opendota?

mdfwn avatar Sep 03 '17 11:09 mdfwn

My main concern is that circumventing Valve's "Expose Public Match Data" setting (which many pros disable) will lead to complaints and therefore Valve shutting down the APIs/access to replays.

Does your script just use the Steam web API? If so, it will not show players who have the setting disabled.

howardchung avatar Sep 03 '17 11:09 howardchung

I thought about that concern as well, I guess it's another discussion whether Valve could or should do this.

But yes, my script is using the steam web API (https://api.steampowered.com/) and identifying pros who don't expose their match data currently works with a look-up table (pairs of pro names and account ids) that I extracted from a web-archive view of dota2tvpro.com (currently only ~60 names though).

Shutting down the API would be awful for the whole community, I personally don't think Valve would ever do this. However, I'm in no place to judge about this, so if you want to keep distance to this kind of feature that circumvents the "Expose Public Match Data" setting I can absolutely understand it and I will keep working on it independently of opendota.

mdfwn avatar Sep 03 '17 12:09 mdfwn

Doesn't the web API hide IDs of players who have the setting disabled by setting it to 2^32 - 1 (4.2 billion)?

howardchung avatar Sep 03 '17 12:09 howardchung

No, it still provides account ids. You just can't use the player API to receive match history etc.

mdfwn avatar Sep 03 '17 12:09 mdfwn

Can you link an example match ID where this is the case?

howardchung avatar Sep 03 '17 12:09 howardchung

I checked and you're partially right - GetMatchDetails does "hide" the real account id the way you explained it. GetTopLiveGame (the function that I use to retreive the games) however shows the real account id, example: https://api.steampowered.com/IDOTA2Match_570/GetTopLiveGame/v1/?key=API_KEY&partner=0 (please provide your own API Key here).

mdfwn avatar Sep 03 '17 12:09 mdfwn

Interesting. Well, since that's an official endpoint and it's not hiding the IDs I assume Valve is OK with it. I'd be open to accepting features utilizing that endpoint.

How complete is the coverage? Are there are some pros whose games don't get picked up by that endpoint?

howardchung avatar Sep 03 '17 12:09 howardchung

I hope I understand your question correctly: yes, basically all players who are considered to be pros but are not part of my current look-up table are missing. As mentioned, I only included ~60 players so far which means that a lot of players - including the whole chinese scene and most of SEA - is still missing. However, I guess that's mostly a question of parsing different dota information sites for account ids of pro players, shouldn't be so hard to "complete" this.

mdfwn avatar Sep 03 '17 12:09 mdfwn

You can use this list that has about 1000 pro players and their IDs:

https://api.opendota.com/api/proPlayers

GetTopLiveGame doesn't appear to have the match ID as one of the fields. How are you planning to map the listed matches to the match ID?

howardchung avatar Sep 03 '17 21:09 howardchung

Oh very convenient, thanks for this list!

GetTopLiveGame doesn't provide a match ID, but a steam_server_id. The steam_server_id is the parameter you can use for GetRealtimeStats (https://api.steampowered.com/IDOTA2MatchStats_570/GetRealtimeStats/v1) which provides you a match ID. Took me some time to find that out...

mdfwn avatar Sep 04 '17 15:09 mdfwn

Sounds good. Did you want to port your existing code to JavaScript and run it as a new service? You can store the resulting data in Redis since it doesn't need to be persisted forever (presumably you just need to list a pro player's recent matches, with links to the match summary page when it's done?)

howardchung avatar Sep 04 '17 20:09 howardchung

I got contacted by someone who wants to help me with the project and the hosting. My short term goal is to get it up & running so everyone can use this kind of site again. It's currently written in Python and Flask/SQLAlchemy. My long term goal is working towards an integration into opendota - however, I have no clue yet how the opendota system is working and what time and effort it will take to port this (especially considering that I haven't written any Javascript in ~5 years).

mdfwn avatar Sep 04 '17 21:09 mdfwn

There'd be three main steps:

  • Add a new service that polls these endpoints, when it finds a match with a pro player on the list, write the data on that match to a data store (like Redis). This would be a standalone JS service in https://github.com/odota/core/tree/master/svc. This should be a pretty straightforward port of the logic in your existing Python script.

  • Add an API endpoint so the UI can access this data. This reads the data you stored earlier. Presumably it would take a player's account ID, and return an array of the recent matches they've participated in. That goes here: https://github.com/odota/core/blob/master/routes/spec.js

  • Add a page to the UI that reads the data from your new endpoint and displays on it a web page. You'd add a new route to the React application here: https://github.com/odota/ui and the result would be a new page e.g. https://www.opendota.com/live

I don't think it would take that much time especially if you've got the logic worked out already. I can help with the porting as well

howardchung avatar Sep 05 '17 04:09 howardchung

Implemented the data endpoint in: https://github.com/odota/core/pull/1543

That's basically steps 1 and 2 listed above.

Once it's deployed anyone who's interested can start working on the UI

https://api.opendota.com/api/live

howardchung avatar Oct 09 '17 03:10 howardchung

How do I add more pro players to this list? https://api.opendota.com/api/proPlayers

evillman avatar Aug 31 '18 16:08 evillman

The list is based on: http://www.dota2.com/webapi/IDOTA2Fantasy/GetProPlayerList/v001

You can mutate it by modifying: https://github.com/odota/core/blob/master/svc/proplayers.js

However if we want to add additional custom data we should find a better long term solution.

howardchung avatar Sep 01 '18 02:09 howardchung

@howardchung are you still interested in the feature? I have a demo web app written in Angular + Node.js, and I'd like to share my codes with you. If possible, I want to integrate it to OpenDota.

HouPoc avatar Apr 09 '19 04:04 HouPoc

Sure! I did some work on this before but haven't shipped it. I wanted to have links open directly to that game in the Dota client, but it didn't work at the time.

howardchung avatar Apr 09 '19 04:04 howardchung

see https://github.com/odota/web/pull/1517

howardchung avatar Apr 09 '19 04:04 howardchung

Cool!

HouPoc avatar Apr 09 '19 04:04 HouPoc

I am not clear about this API steam://rungameid/570//watch_server ${game.server_steam_id}? What did you want to do with it?

HouPoc avatar Apr 09 '19 05:04 HouPoc

It doesn't work, but the idea is to have that link launch the Dota client and immediately start spectating that game.

howardchung avatar Apr 09 '19 05:04 howardchung

How about we try this (https://api.steampowered.com/IDOTA2MatchStats_570/GetRealtimeStats/v1)? From this API, I got some data about the characters' position on minimap, networth, abilities, items, and etc. here is a sample: https://github.com/HouPoc/DOTA2_VisLive/blob/master/data.json

HouPoc avatar Apr 09 '19 05:04 HouPoc

What I did was using minimap_icon to represent heroes and putting them on a div whose background is mini_map. Then, I updated those minimap_cion's positions in real-time to visualize the movements.

HouPoc avatar Apr 09 '19 05:04 HouPoc

It works like trackdota.com.

HouPoc avatar Apr 09 '19 05:04 HouPoc

Yeah, that data currently isn't being sent down, but it could be (see the commented out code): https://github.com/odota/core/blob/master/svc/livegames.js

howardchung avatar Apr 09 '19 05:04 howardchung

Yeah, that data currently isn't being sent down, but it could be (see the commented out code): https://github.com/odota/core/blob/master/svc/livegames.js Can we keep working on it?

HouPoc avatar Apr 09 '19 05:04 HouPoc

I did enjoy doing it..

HouPoc avatar Apr 09 '19 05:04 HouPoc

Sure, feel free to make a PR there as well if you want to add the additional data

howardchung avatar Apr 09 '19 05:04 howardchung