vduits / streamer-endpoints

Rest endpoints meant for usage with nightbot in twitch
MIT License
0 stars 1 forks source link

Create service that retrieves the currently played game by a certain user. #3

Closed vduits closed 3 years ago

vduits commented 3 years ago

In the steps to support IGDB we want a method in the TwitchAPI class or derivative that communicates with the Twitch API to retrieve the game a user currently plays. Additionally we want to create a new service that calls this method. Exposing the resulting information from the genuine Twitch API response is currently sufficient as the String response

davidwisniowski commented 3 years ago

i could build it if you want. would use the api endpoint: https://dev.twitch.tv/docs/v5/reference/streams#get-stream-by-user

vduits commented 3 years ago

V5/Kraken is deprecated, so it I would like to see Helix used instead. It has a query param with user_id.

5 added some changes so I have updated the issue. I'm intending to update the code with some extra documentation soon to make it a bit easier to understand it. Let me know at what pace you want to work at if it you are still interested, then I can prioritise adding the doc titbits :).

davidwisniowski commented 3 years ago

Ah, the helix api. sorry, pretty new to the twitch api (but i know twitch) and I would like to contribute to this project. you don't have to hurry. i can read the code very well. generally i have time in the evening every day. i would like to help you with some things.

vduits commented 3 years ago

Alright, no problem. The extra bits will be there by the end of the weekend regardless. If you have any additional questions let me know. If you never worked with java/spring ecosystem it can always be bit tricky so don't hesitate to drop any questions or problems you encounter.

This is one of a few issues I intended to hand out to people that want to join Hactoberfest, while trying to include a few more features to this system. You just dropped in a bit early before I could prep it all up. If your code works as intended I can flag the PR with the required tag if you wish to work towards getting that t-shirt.

davidwisniowski commented 3 years ago

i already have spring boot experience, all good, thanks! i have the application running locally and the feature is ready. you could move the methods retrieveUserFromString, retrieveUserIdFromName and buildUrl and put them in a Utils class so they are available globally.

i followed the twitch api and built a StreamController and StreamService. currently with duplicate methods because the above methods are only in the userservice (bad practise). i will wait for the answers about the Utils Class und Utils Method.

The Api call would be and will print the current playing game id. do you need the id or the game name?

/stream/{username}/game

vduits commented 3 years ago

Yeah the intention was to move common user service class based functions out. That was the original intention for checkbox n4, up to you if you want to do extract them now or if I will later.

The Api call would be and will print the current playing game id. do you need the id or the game name?

Both. The ID is sufficient enough for most future IGDB requests (they keep it as an external game id), but there might be a few edge cases like just-chatting and alike that won't appear on IGDB. Having the name means it'll be easier to figure out why in logging later.

davidwisniowski commented 3 years ago

Thanks for your quick answer.

Okay, nice. I will create a todo comment above the duplicate methods. lets create for that another issue/task to seperate things.

last question about the game id and game name. do you want different api points for them?

/stream/{username}/game/id

/stream/{username}/game/name

or do you want one single api point with an json object with both values?

vduits commented 3 years ago

Sorry, the negative side of quick replies in between working is lack of attention. No endpoint is needed right now. This issue was simply for a service/methods that will be used later in the actual endpoints.

For the entire picture of the 'epic': This issue is to grab the currently played game by the streamer from twitch. Up next would be to then retrieve game information from IGDB. That information could then be exposed on several endpoints again for usage inside their own chatbot like nightbot/streamlabs bots. Just retrieving what game people play is already natively supported by a lot of those bots, so there's no need for us to add that feature.

For now creating a POJO from the data that contains the game id/name is enough. Issues for the IGDB integration will come somewhere this weekend once I spoke with a few streamers what they would like to see.

Issues to improve the codebase are always welcome, this is quite an old one and this month's sparkup is also to address that legacy. The transformation from JSON can also be improved by using more mapping style behaviour instead so that will likely also become an additional issue. Let me know if you see any other glaring issues and I'll add that to the more refactor styled issues that are coming up.