]>
Commit | Line | Data |
---|---|---|
c08b8873 DA |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | try_get, | |
5 | unified_timestamp, | |
6 | ) | |
7 | ||
8 | ||
9 | class CiscoWebexIE(InfoExtractor): | |
10 | IE_NAME = 'ciscowebex' | |
11 | IE_DESC = 'Cisco Webex' | |
12 | _VALID_URL = r'''(?x) | |
13 | (?P<url>https?://(?P<subdomain>[^/#?]*)\.webex\.com/(?: | |
14 | (?P<siteurl_1>[^/#?]*)/(?:ldr|lsr).php\?(?:[^#]*&)*RCID=(?P<rcid>[0-9a-f]{32})| | |
15 | (?:recordingservice|webappng)/sites/(?P<siteurl_2>[^/#?]*)/recording/(?:playback/|play/)?(?P<id>[0-9a-f]{32}) | |
16 | ))''' | |
17 | ||
18 | _TESTS = [{ | |
19 | 'url': 'https://demosubdomain.webex.com/demositeurl/ldr.php?RCID=e58e803bc0f766bb5f6376d2e86adb5b', | |
20 | 'only_matching': True, | |
21 | }, { | |
22 | 'url': 'http://demosubdomain.webex.com/demositeurl/lsr.php?RCID=bc04b4a7b5ea2cc3a493d5ae6aaff5d7', | |
23 | 'only_matching': True, | |
24 | }, { | |
25 | 'url': 'https://demosubdomain.webex.com/recordingservice/sites/demositeurl/recording/88e7a42f7b19f5b423c54754aecc2ce9/playback', | |
26 | 'only_matching': True, | |
27 | }] | |
28 | ||
29 | def _real_extract(self, url): | |
30 | mobj = self._match_valid_url(url) | |
31 | rcid = mobj.group('rcid') | |
32 | if rcid: | |
33 | webpage = self._download_webpage(url, None, note='Getting video ID') | |
34 | url = self._search_regex(self._VALID_URL, webpage, 'redirection url', group='url') | |
35 | url = self._request_webpage(url, None, note='Resolving final URL').geturl() | |
36 | mobj = self._match_valid_url(url) | |
37 | subdomain = mobj.group('subdomain') | |
38 | siteurl = mobj.group('siteurl_1') or mobj.group('siteurl_2') | |
39 | video_id = mobj.group('id') | |
40 | ||
41 | stream = self._download_json( | |
42 | 'https://%s.webex.com/webappng/api/v1/recordings/%s/stream' % (subdomain, video_id), | |
43 | video_id, fatal=False, query={'siteurl': siteurl}) | |
44 | if not stream: | |
45 | self.raise_login_required(method='cookies') | |
46 | ||
47 | video_id = stream.get('recordUUID') or video_id | |
48 | ||
49 | formats = [{ | |
50 | 'format_id': 'video', | |
51 | 'url': stream['fallbackPlaySrc'], | |
52 | 'ext': 'mp4', | |
53 | 'vcodec': 'avc1.640028', | |
54 | 'acodec': 'mp4a.40.2', | |
55 | }] | |
56 | if stream.get('preventDownload') is False: | |
57 | mp4url = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['mp4URL']) | |
58 | if mp4url: | |
59 | formats.append({ | |
60 | 'format_id': 'video', | |
61 | 'url': mp4url, | |
62 | 'ext': 'mp4', | |
63 | 'vcodec': 'avc1.640028', | |
64 | 'acodec': 'mp4a.40.2', | |
65 | }) | |
66 | audiourl = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['audioURL']) | |
67 | if audiourl: | |
68 | formats.append({ | |
69 | 'format_id': 'audio', | |
70 | 'url': audiourl, | |
71 | 'ext': 'mp3', | |
72 | 'vcodec': 'none', | |
73 | 'acodec': 'mp3', | |
74 | }) | |
75 | self._sort_formats(formats) | |
76 | ||
77 | return { | |
78 | 'id': video_id, | |
79 | 'title': stream['recordName'], | |
80 | 'description': stream.get('description'), | |
81 | 'uploader': stream.get('ownerDisplayName'), | |
82 | 'uploader_id': stream.get('ownerUserName') or stream.get('ownerId'), # mail or id | |
83 | 'timestamp': unified_timestamp(stream.get('createTime')), | |
84 | 'duration': int_or_none(stream.get('duration'), 1000), | |
85 | 'webpage_url': 'https://%s.webex.com/recordingservice/sites/%s/recording/playback/%s' % (subdomain, siteurl, video_id), | |
86 | 'formats': formats, | |
87 | } |