Advertisement
authorblues

Untitled

Sep 23rd, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def get_twitch_gif(user):
  2.     videos = get_json('https://api.twitch.tv/kraken/channels/{}/videos?limit=1&broadcasts=true&hls=true'.format(user))
  3.     vidid = video['videos'][0]['_id']
  4.     if vidid is None: return None
  5.    
  6.     vid = get_json('https://api.twitch.tv/kraken/videos/{}'.format(vidid))
  7.     if 'v1/AUTH_system' not in vid['preview']: return None
  8.    
  9.     index = '/'.join(vid['preview'].split('/')[3:7])
  10.     url = 'http://vod.ak.hls.ttvnw.net/{}/chunked/index-dvr.m3u8'.format(index)
  11.     # the .m3u8 file contains enough information to work with here...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement