def play(self, videoId): api = NetworkTenVideo() media = api.get_media_for_video(videoId) self.log.debug("Found media renditions for video: %s", repr(media.items)) if len(media.items): # Blindly go for the highest bitrate for now. # Later versions could include a customisable setting of which stream to use media_sorted = sorted(media.items, key=lambda m: m.encodingRate, reverse=True) media = media_sorted[0] path = media.defaultURL self.log.info("Using rendition: %s with url: %s" % (media, path)) else: # Fallback to API FLVFullLength (e.g. for live streams) media = api.get_fallback_media_for_video(videoId) path = media.remoteUrl self.log.info("Using fallback rendition: %s with url: %s" % (media, path)) if path.startswith("rtmp"): path = path.replace("&mp4:", " playpath=mp4:") path += " swfVfy=true swfUrl=%s pageUrl=%s" % (SWF_URL, PAGE_URL) # Set the resolved url, and include media stream info item = ListItem.from_dict(path=path) item.add_stream_info( "video", {"codec": media.videoCodec, "width": media.frameWidth, "height": media.frameHeight} ) self.plugin.set_resolved_url(path)
def play(self, videoId): api = NetworkTenVideo() media = api.get_media_for_video(videoId) self.log.debug('Found media renditions for video: %s', repr(media.items)) if len(media.items): # Blindly go for the highest bitrate for now. # Later versions could include a customisable setting of which stream to use media_sorted = sorted(media.items, key=lambda m: m.encodingRate, reverse=True) media = media_sorted[0] path = media.defaultURL self.log.info('Using rendition: %s with url: %s' % (media, path)) else: # Fallback to API FLVFullLength (e.g. for live streams) media = api.get_fallback_media_for_video(videoId) path = media.remoteUrl self.log.info('Using fallback rendition: %s with url: %s' % (media, path)) if path.startswith('rtmp'): path = path.replace('&mp4:', ' playpath=mp4:') path += ' swfVfy=true swfUrl=%s pageUrl=%s' % (SWF_URL, PAGE_URL) # Set the resolved url, and include media stream info item = ListItem.from_dict(path=path) item.add_stream_info( 'video', { 'codec': media.videoCodec, 'width': media.frameWidth, 'height': media.frameHeight }) self.plugin.set_resolved_url(path)
def play(self, videoId): api = NetworkTenVideo() media = api.get_media_for_video(videoId) self.log.debug('Found media renditions for video: %s', repr(media)) if len(media): # Blindly go for the highest bitrate for now. # Later versions could include a customisable setting of which stream to use media_sorted = sorted(media, key=lambda m: m.encodingRate, reverse=True) media = media_sorted[0] path = media.url self.log.info('Using rendition: %s with url: %s' % (media, path)) else: # Fallback to API FLVFullLength (e.g. for live streams) media = api.get_fallback_media_for_video(videoId) if media.remoteUrl: path = media.remoteUrl self.log.info('Using fallback rendition: %s with url: %s' % (media, path)) else: # attempt to deal with DRM'd content by falling back to mobile HLS stream path = "http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=%s" % videoId self.log.info('Using fallback rendition unavailable - falling back to mobile HLS stream: %s' % path) if path.startswith('rtmp'): path = path.replace('&mp4:', ' playpath=mp4:') path += ' swfVfy=true swfUrl=%s pageUrl=%s' % (SWF_URL, PAGE_URL) # Set the resolved url, and include media stream info item = ListItem.from_dict(path=path) item.add_stream_info('video', {'codec': media.videoCodec, 'width': media.frameWidth, 'height': media.frameHeight}) self.plugin.set_resolved_url(path)