Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TechplexEngineer/78202e8eb9cdd772222887d7b213fa13 to your computer and use it in GitHub Desktop.
Save TechplexEngineer/78202e8eb9cdd772222887d7b213fa13 to your computer and use it in GitHub Desktop.
def main():
client = TwitchClient(client_id='a57grsx9fi8ripztxn8zbxhnvek4cp')
# Monkey patch TwitchClient.users to add get_by_name https://github.com/tsifrer/python-twitch-client/pull/52
from types import MethodType
from twitch.resources import User
def get_by_name(self, user_ids):
if isinstance(user_ids, str):
user_ids = [user_ids]
params = {
'login': ','.join(user_ids)
}
response = self._request_get('users', params=params)
return User.construct_from(response)
client.users.get_by_name = MethodType(get_by_name, client.users)
result = client.users.get_by_name('nefirst_red')
if result['total'] > 1:
print('Found more than one user by that name')
return
if result['total'] < 1:
print('Unable to find a user by that name')
return
user = result['users'][0]
# print(user['_id'])
# curl -H 'Accept: application/vnd.twitchtv.v5+json' \
# -H 'Client-ID: a57grsx9fi8ripztxn8zbxhnvek4cp' \
# -X GET 'https://api.twitch.tv/kraken/channels/83339810/videos'
for video in client.channels.get_videos(user['_id'], limit=100, broadcast_type=''):
print(video.title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment