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 check_video(id, expected_path): video = usher.video(id) video_path = video['path'] assert video_path == expected_path