@@ -326,7 +326,7 @@ def get_todays(cls, make_obj=True, sections=''):
326
326
result = super (FloorUpdates , cls )._apicall (endpoint , sections , make_obj , ** params )
327
327
return result ['floor_updates' ]
328
328
329
- class Videos (RTC_Client ):
329
+ class HouseVideos (RTC_Client ):
330
330
""" Currently only supports house type videos """
331
331
__help__ = RTC_helpers .VIDEO_HELPER
332
332
@@ -337,27 +337,29 @@ def __str__(self):
337
337
def get_by_bill (cls , bill_id , make_obj = False , sections = ('clip_urls' , 'duration' ,
338
338
'legislative_day' , 'clip_id' ,
339
339
'video_id' , 'bills' , 'clips' )):
340
- """
341
-
342
- """
343
340
endpoint = "videos.json"
344
341
params = {'clips.bills' : bill_id }
345
- results = super (Videos , cls )._apicall (endpoint , sections , make_obj , ** params )
342
+ results = super (HouseVideos , cls )._apicall (endpoint , sections , make_obj , ** params )
346
343
### Only include clips from each video that contain bill_id ###
347
344
videos = []
348
345
for v in results ['videos' ]:
349
346
if v .has_key ('bills' ) and bill_id in v ['bills' ]:
350
- videos .append (v )
351
- #################################################
347
+ clips = []
348
+ for c in v ['clips' ]:
349
+ if c .has_key ('bills' ) and bill_id in c ['bills' ]:
350
+ clips .append (c )
351
+ if len (clips ) > 0 :
352
+ v ['clips' ] = clips
353
+ videos .append (v )
352
354
return videos
353
355
354
356
@classmethod
355
- def get_legislator_name (cls , name , make_obj = False , sections = ('clip_urls' , 'duration' ,
357
+ def get_by_legislator_name (cls , name , make_obj = False , sections = ('clip_urls' , 'duration' ,
356
358
'legislative_day' , 'clip_id' ,
357
359
'video_id' , 'bills' , 'clips' )):
358
360
endpoint = "videos.json"
359
361
params = {'clips.legislator_names' : name }
360
- results = super (Videos , cls )._apicall (endpoint , sections , make_obj , ** params )
362
+ results = super (HouseVideos , cls )._apicall (endpoint , sections , make_obj , ** params )
361
363
### Only include clips from each video that contain a legistrators name
362
364
# Make sure results set has the legislators name sin it
363
365
videos = []
@@ -374,7 +376,32 @@ def get_legislator_name(cls, name, make_obj=False, sections=('clip_urls', 'durat
374
376
v ['clips' ] = clips
375
377
videos .append (v )
376
378
377
- #################################################
379
+ return videos
380
+
381
+
382
+ @classmethod
383
+ def get_by_bioguide_id (cls , bioguide_id , make_obj = False , sections = ('clip_urls' , 'duration' ,
384
+ 'legislative_day' , 'clip_id' ,
385
+ 'video_id' , 'bills' , 'clips' )):
386
+ endpoint = "videos.json"
387
+ params = {'clips.bioguide_ids' : bioguide_id }
388
+ results = super (HouseVideos , cls )._apicall (endpoint , sections , make_obj , ** params )
389
+ ### Only include clips from each video that contain a legistrators name
390
+ # Make sure results set has the legislators name sin it
391
+ videos = []
392
+ for v in results ['videos' ]:
393
+ # Json examples in the documentation say there will be a
394
+ # legislator_names however in practice they are not there
395
+ #if v.has_key('bioguide_id') and name in v['bioguide_id']:
396
+ clips = []
397
+ for c in v ['clips' ]:
398
+ if c .has_key ('bioguide_ids' ) and bioguide_id in c ['bioguide_ids' ]:
399
+ clips .append (c )
400
+
401
+ if len (clips ) > 0 :
402
+ v ['clips' ] = clips
403
+ videos .append (v )
404
+
378
405
return videos
379
406
380
407
class Amendments (RTC_Client ):
0 commit comments