def get_media_for_video(self, videoId=None, video=None): # Note to self: Although we *can* access the video content via the Media API # (docs: http://support.brightcove.com/en/video-cloud/docs/accessing-video-content-media-api) # and it's much easier/flexible, we aren't so as not to arouse suspicion and to future proof the library #self.brightcove.find_video_by_id(video.id, fields='length,renditions,FLVURL') amfHelper = BrightCoveAMFHelper(PLAYER_KEY, videoId, PAGE_URL, AMF_SEED) if amfHelper.data: return get_item({'items': amfHelper.data['renditions']}, MediaRenditionItemCollection) else: return get_item({'items': []}, MediaRenditionItemCollection)
def get_playlists_for_show(self, show): resp = self._request(SHOWDATA_URL) json_data = json.loads(resp) for showSearch in json_data['shows']: if showSearch['showName'] == show: return get_item({'items': showSearch['playlists']}, PlaylistItemCollection) return None
def get_show(self, show): resp = self._request(SHOWDATA_URL) json_data = json.loads(resp) for showSearch in json_data['shows']: if showSearch['showName'] == show: return get_item(showSearch, Show) return None
def _read_api(self, command, params, cls=None): '''Pases the JSON response for a given API command to a constructor of the provided cls and returns the result. ''' params.update({'command': command}) resp = self.read_conn.get_request(READ_API_URL, params) _json = json.loads(resp) # try, ValueError if not json assert 'error' not in _json, 'API Error [%d]: %s' % (_json['code'], _json['error']) if cls: return get_item(_json, cls) return _json
def test_get_item_dict(self): kwargs = {u'bar': 'bar', u'baz': 'baz'} item = get_item(kwargs, self.Bar) self.assertEqual(item.bar, 'bar') self.assertEqual(item.baz, 'baz')
def get_fallback_media_for_video(self, videoId=None): video = self.brightcove.find_video_by_id(videoId, video_fields='FLVFullLength') if video.FLVFullLength: media = get_item(video.FLVFullLength, AMFRendition) return media