1 from .common
import InfoExtractor
4 compat_urllib_parse_unquote
,
16 class GaiaIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?gaia\.com/video/(?P<id>[^/?]+).*?\bfullplayer=(?P<type>feature|preview)'
19 'url': 'https://www.gaia.com/video/connecting-universal-consciousness?fullplayer=feature',
23 'title': 'Connecting with Universal Consciousness',
24 'description': 'md5:844e209ad31b7d31345f5ed689e3df6f',
25 'upload_date': '20151116',
26 'timestamp': 1447707266,
31 'skip_download': True,
34 'url': 'https://www.gaia.com/video/connecting-universal-consciousness?fullplayer=preview',
38 'title': 'Connecting with Universal Consciousness',
39 'description': 'md5:844e209ad31b7d31345f5ed689e3df6f',
40 'upload_date': '20151116',
41 'timestamp': 1447707266,
46 'skip_download': True,
49 _NETRC_MACHINE
= 'gaia'
52 def _real_initialize(self
):
53 auth
= self
._get
_cookies
('https://www.gaia.com/').get('auth')
55 auth
= self
._parse
_json
(compat_urllib_parse_unquote(auth
.value
), None, fatal
=False)
56 self
._jwt
= auth
.get('jwt')
58 def _perform_login(self
, username
, password
):
61 auth
= self
._download
_json
(
62 'https://auth.gaia.com/v1/login',
63 None, data
=urlencode_postdata({
67 if auth
.get('success') is False:
68 raise ExtractorError(', '.join(auth
['messages']), expected
=True)
69 self
._jwt
= auth
.get('jwt')
71 def _real_extract(self
, url
):
72 display_id
, vtype
= self
._match
_valid
_url
(url
).groups()
73 node_id
= self
._download
_json
(
74 'https://brooklyn.gaia.com/pathinfo', display_id
, query
={
75 'path': 'video/' + display_id
,
77 node
= self
._download
_json
(
78 'https://brooklyn.gaia.com/node/%d' % node_id
, node_id
)
80 media_id
= compat_str(vdata
['nid'])
85 headers
= {'Authorization': 'Bearer ' + self._jwt}
86 media
= self
._download
_json
(
87 'https://brooklyn.gaia.com/media/' + media_id
,
88 media_id
, headers
=headers
)
89 formats
= self
._extract
_m
3u8_formats
(
90 media
['mediaUrls']['bcHLS'], media_id
, 'mp4')
93 text_tracks
= media
.get('textTracks', {})
94 for key
in ('captions', 'subtitles'):
95 for lang
, sub_url
in text_tracks
.get(key
, {}).items():
96 subtitles
.setdefault(lang
, []).append({
100 fivestar
= node
.get('fivestar', {})
101 fields
= node
.get('fields', {})
103 def get_field_value(key
, value_key
='value'):
104 return try_get(fields
, lambda x
: x
[key
][0][value_key
])
108 'display_id': display_id
,
111 'description': strip_or_none(get_field_value('body') or get_field_value('teaser')),
112 'timestamp': int_or_none(node
.get('created')),
113 'subtitles': subtitles
,
114 'duration': int_or_none(vdata
.get('duration')),
115 'like_count': int_or_none(try_get(fivestar
, lambda x
: x
['up_count']['value'])),
116 'dislike_count': int_or_none(try_get(fivestar
, lambda x
: x
['down_count']['value'])),
117 'comment_count': int_or_none(node
.get('comment_count')),
118 'series': try_get(node
, lambda x
: x
['series']['title'], compat_str
),
119 'season_number': int_or_none(get_field_value('season')),
120 'season_id': str_or_none(get_field_value('series_nid', 'nid')),
121 'episode_number': int_or_none(get_field_value('episode')),