A Personalized Twitch Resources Recommendation Engine 3
Implement a content-based recommendation function for Twitch contents.
Item-based Recommendation vs Content-based Recommendation
Item-based recommendation is totally based on user-item ranking
content-based is that we have to know the content of both user and item
Content-based filtering system: Content-Based recommender system tries to guess the features or behavior of a user given the item’s features, he/she reacts positively to.
Content-based filtering does not require other users' data during recommendations to one user.
Backend Code Structure
get token form Twitch
- register in dev.twitch, get Client_id and Client_secret ready
- open postman and the Twitch token generate request to get the access token for calling Twitch APIs
{
"access_token": "ddx06i6thux3yl5v1jnugx9mqrk8kt",
"expires_in": 5670001,
"token_type": "bearer"
}
- test,get top games
postman, set up the {{ACCESS_TOKEN}} and {{CLIENT_ID}}
- success
{
"data": [
{
"id": "509658",
"name": "Just Chatting",
"box_art_url": "https://static-cdn.jtvnw.net/ttv-boxart/509658-{width}x{height}.jpg",
"igdb_id": ""
},
{....
}
}
Now the token is working.
Connect to Twitch API with Java
1. RESTful Java client with Apache HttpClient
CloseableHttpClient httpclient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = response -> {
int responseCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
2. Update Game Class to Match Twitch Response
public class Game{
}
3. Create a new package for the external APIs
get top games
- TwitchClient:topGame
- TwitchClient:searchGame
- TwitchClient:searTwitch
test
from the api.twitch to localhost:8080,
http://localhost:8080/jupiter/game?game_name=Starcraft II
Client
- SerchServlet: doGet
- TwitchClient:searchItems
- TwitchClient:searchByType
- TwitchClient:searchStream
- TwitchClient:searchVideo
- TwitchClient:searchClips
- TwitchClient:searchByType
- TwitchClient:searchItems
- TwitchClient:searTwitch Twitch
1. Add Item Class to Match Twitch Response
ItemType: STREAM, VIDEO, CLIP
2. Add method in TwitchClient
goals
https://api.twitch.tv/helix/videos?game_id=12000 https://api.twitch.tv/helix/clips?game_id=12000
http://localhost:8080/jupiter/search?game_id=100000