blackboardcollaborate.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from .common import InfoExtractor
  2. from ..utils import parse_iso8601
  3. class BlackboardCollaborateIE(InfoExtractor):
  4. _VALID_URL = r'''(?x)
  5. https?://
  6. (?P<region>[a-z-]+)\.bbcollab\.com/
  7. (?:
  8. collab/ui/session/playback/load|
  9. recording
  10. )/
  11. (?P<id>[^/]+)'''
  12. _TESTS = [
  13. {
  14. 'url': 'https://us-lti.bbcollab.com/collab/ui/session/playback/load/0a633b6a88824deb8c918f470b22b256',
  15. 'md5': 'bb7a055682ee4f25fdb5838cdf014541',
  16. 'info_dict': {
  17. 'id': '0a633b6a88824deb8c918f470b22b256',
  18. 'title': 'HESI A2 Information Session - Thursday, May 6, 2021 - recording_1',
  19. 'ext': 'mp4',
  20. 'duration': 1896000,
  21. 'timestamp': 1620331399,
  22. 'upload_date': '20210506',
  23. },
  24. },
  25. {
  26. 'url': 'https://us.bbcollab.com/collab/ui/session/playback/load/76761522adfe4345a0dee6794bbcabda',
  27. 'only_matching': True,
  28. },
  29. {
  30. 'url': 'https://ca.bbcollab.com/collab/ui/session/playback/load/b6399dcb44df4f21b29ebe581e22479d',
  31. 'only_matching': True,
  32. },
  33. {
  34. 'url': 'https://eu.bbcollab.com/recording/51ed7b50810c4444a106e48cefb3e6b5',
  35. 'only_matching': True,
  36. },
  37. {
  38. 'url': 'https://au.bbcollab.com/collab/ui/session/playback/load/2bccf7165d7c419ab87afc1ec3f3bb15',
  39. 'only_matching': True,
  40. },
  41. ]
  42. def _real_extract(self, url):
  43. mobj = self._match_valid_url(url)
  44. region = mobj.group('region')
  45. video_id = mobj.group('id')
  46. info = self._download_json(
  47. f'https://{region}.bbcollab.com/collab/api/csa/recordings/{video_id}/data', video_id)
  48. duration = info.get('duration')
  49. title = info['name']
  50. upload_date = info.get('created')
  51. streams = info['streams']
  52. formats = [{'format_id': k, 'url': url} for k, url in streams.items()]
  53. return {
  54. 'duration': duration,
  55. 'formats': formats,
  56. 'id': video_id,
  57. 'timestamp': parse_iso8601(upload_date),
  58. 'title': title,
  59. }