r/PythonProjects2 • u/vvinvardhan • Feb 13 '22
[P] Moderate Made this twitter bot using python that tweets out streams with 0 viewers! I love talking to people with 0 viewers, seeing them light up makes my day. Hoping this would spread that joy!
https://twitter.com/no_viewers2
u/Whatupcraig Feb 14 '22
Mind posting the code? I’d love to see how you interacted with twitch.
0
u/vvinvardhan Feb 14 '22
umm, I don't wanna post all the code! This could be a great learning opportunity for you!
Twitch has a robust API setup which you can use! These are the API endpoints I ended up using. This is a good place to start
#for access token f"https://id.twitch.tv/oauth2/token?client_id={twitch_client_id}&client_secret={twitch_client_secret}&grant_type=client_credentials" #getting game_id from a query f"https://api.twitch.tv/helix/search/categories?query={gamehere}" #getting english language streams in batches of 100 f"https://api.twitch.tv/helix/streams?game_id={game_id}&first=100&language=en" #and you can paginate using the Cursor provided in the Pagination part of the json data
1
u/mat2358 Feb 14 '22
This is a cool idea. Would love to know how this works.
Fyi most people with 1 viewer are the same as 0 based on how Twitch reads people viewing their own dashboards.
2
u/vvinvardhan Feb 14 '22
yea, but the way twitch api works, it paginates the results. So if I stop at 1 it will not get to people with 0 viewers! and I thought 0 viewers would sound more interesting!
I don't know, how would you approach this problem!
1
u/GrGadget Feb 17 '22
I'm assuming this is run in a while loop? I may be totally wrong, could you not run a second query? For 0 and 1.
1
u/vvinvardhan Feb 17 '22
correct. I will do that. Its gonna take me a while to get to that because I am a little busy with work right now. But I will do it.
The problem I had was not a programming one, it was an ethical one! Thanks for the input
1
4
u/Sonictrade Feb 13 '22
Could u post code would love to learn