2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
14 class GoToStageIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?gotostage\.com/channel/[a-z0-9]+/recording/(?P<id>[a-z0-9]+)/watch'
17 'url': 'https://www.gotostage.com/channel/8901680603948959494/recording/60bb55548d434f21b9ce4f0e225c4895/watch',
18 'md5': 'ca72ce990cdcd7a2bd152f7217e319a2',
20 'id': '60bb55548d434f21b9ce4f0e225c4895',
22 'title': 'What is GoToStage?',
23 'thumbnail': r
're:^https?://.*\.jpg$',
27 'url': 'https://www.gotostage.com/channel/bacc3d3535b34bafacc3f4ef8d4df78a/recording/831e74cd3e0042be96defba627b6f676/watch?source=HOMEPAGE',
28 'only_matching': True,
31 def _real_extract(self
, url
):
32 video_id
= self
._match
_id
(url
)
33 metadata
= self
._download
_json
(
34 'https://api.gotostage.com/contents?ids=%s' % video_id
,
36 note
='Downloading video metadata',
37 errnote
='Unable to download video metadata')[0]
40 'product': metadata
['product'],
41 'resourceType': metadata
['contentType'],
42 'productReferenceKey': metadata
['productRefKey'],
45 'email': 'foobar@example.com'
48 registration_response
= self
._download
_json
(
49 'https://api-registrations.logmeininc.com/registrations',
51 data
=json
.dumps(registration_data
).encode(),
53 headers
={'Content-Type': 'application/json'}
,
55 errnote
='Unable to register user')
57 content_response
= self
._download
_json
(
58 'https://api.gotostage.com/contents/%s/asset' % video_id
,
60 headers
={'x-registrantkey': registration_response['registrationKey']}
,
61 note
='Get download url',
62 errnote
='Unable to get download url')
66 'title': try_get(metadata
, lambda x
: x
['title'], compat_str
),
67 'url': try_get(content_response
, lambda x
: x
['cdnLocation'], compat_str
),
69 'thumbnail': url_or_none(try_get(metadata
, lambda x
: x
['thumbnail']['location'])),
70 'duration': try_get(metadata
, lambda x
: x
['duration'], float),
71 'categories': [try_get(metadata
, lambda x
: x
['category'], compat_str
)],