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