Exemplo n.º 1
0
 def get_media_url(self, host, media_id):
     queries.CLIENT_ID = self.get_setting('client_id')
     videos = None
     if media_id.count('/') == 0:
         try:
             videos = usher.live(media_id)
         except ResourceUnavailableException as e:
             raise ResolverError(e.message)
     else:
         url = self.get_url(host, media_id)
         video_id = self._extract_video(url)
         if video_id:
             videos = usher.video(video_id)
             try:
                 pass
             except ResourceUnavailableException as e:
                 raise ResolverError(e.message)
     if videos:
         if 'error' in videos:
             raise ResolverError('[%s] %s' %
                                 (str(videos['status']), videos['message']))
         sources = [(source['name'], source['url']) for source in videos]
         return helpers.pick_source(sources)
     else:
         raise ResolverError('No streamer name or VOD ID found')
 def test_resolve_top_featured(self):
     featured_name = twitch.streams.featured()['featured'][0]['stream']['channel']['name']
     r = usher.live(featured_name)
     self.assertNotEqual(r, {})
     for quality, url in six.iteritems(r):
         self.assertIn(quality, self.possible_qualities)
         self.assertIn('http://', url)
Exemplo n.º 3
0
 def test_resolve_top_featured(self):
     featured_name = twitch.streams.featured(
     )['featured'][0]['stream']['channel']['name']
     r = usher.live(featured_name)
     self.assertNotEqual(r, {})
     for quality, url in six.iteritems(r):
         self.assertIn(quality, self.possible_qualities)
         self.assertIn('http://', url)
Exemplo n.º 4
0
 def get_media_url(self, host, media_id):
     queries.CLIENT_ID = self.get_setting('client_id')
     videos = None
     if media_id.count('/') == 0:
         try:
             videos = usher.live(media_id)
         except ResourceUnavailableException as e:
             raise ResolverError(e.message)
     else:
         url = self.get_url(host, media_id)
         video_id = self._extract_video(url)
         if video_id:
             videos = usher.video(video_id)
             try:
                 pass
             except ResourceUnavailableException as e:
                 raise ResolverError(e.message)
     if videos:
         if 'error' in videos:
             raise ResolverError('[%s] %s' % (str(videos['status']), videos['message']))
         sources = [(source['name'], source['url']) for source in videos]
         return helpers.pick_source(sources)
     else:
         raise ResolverError('No streamer name or VOD ID found')
 def test_live_offline(self):
     with self.assertRaises(ResourceUnavailableException):
         usher.live('test_channel')
Exemplo n.º 6
0
 def test_live_offline(self):
     with self.assertRaises(ResourceUnavailableException):
         usher.live('test_channel')