3 from .common
import InfoExtractor
4 from ..compat
import compat_str
5 from ..utils
import try_get
, url_or_none
8 class GoToStageIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?gotostage\.com/channel/[a-z0-9]+/recording/(?P<id>[a-z0-9]+)/watch'
11 'url': 'https://www.gotostage.com/channel/8901680603948959494/recording/60bb55548d434f21b9ce4f0e225c4895/watch',
12 'md5': 'ca72ce990cdcd7a2bd152f7217e319a2',
14 'id': '60bb55548d434f21b9ce4f0e225c4895',
16 'title': 'What is GoToStage?',
17 'thumbnail': r
're:^https?://.*\.jpg$',
21 'url': 'https://www.gotostage.com/channel/bacc3d3535b34bafacc3f4ef8d4df78a/recording/831e74cd3e0042be96defba627b6f676/watch?source=HOMEPAGE',
22 'only_matching': True,
25 def _real_extract(self
, url
):
26 video_id
= self
._match
_id
(url
)
27 metadata
= self
._download
_json
(
28 'https://api.gotostage.com/contents?ids=%s' % video_id
,
30 note
='Downloading video metadata',
31 errnote
='Unable to download video metadata')[0]
34 'product': metadata
['product'],
35 'resourceType': metadata
['contentType'],
36 'productReferenceKey': metadata
['productRefKey'],
39 'email': 'foobar@example.com'
42 registration_response
= self
._download
_json
(
43 'https://api-registrations.logmeininc.com/registrations',
45 data
=json
.dumps(registration_data
).encode(),
47 headers
={'Content-Type': 'application/json'}
,
49 errnote
='Unable to register user')
51 content_response
= self
._download
_json
(
52 'https://api.gotostage.com/contents/%s/asset' % video_id
,
54 headers
={'x-registrantkey': registration_response['registrationKey']}
,
55 note
='Get download url',
56 errnote
='Unable to get download url')
60 'title': try_get(metadata
, lambda x
: x
['title'], compat_str
),
61 'url': try_get(content_response
, lambda x
: x
['cdnLocation'], compat_str
),
63 'thumbnail': url_or_none(try_get(metadata
, lambda x
: x
['thumbnail']['location'])),
64 'duration': try_get(metadata
, lambda x
: x
['duration'], float),
65 'categories': [try_get(metadata
, lambda x
: x
['category'], compat_str
)],