3 from .common
import InfoExtractor
14 class GaiaIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?gaia\.com/video/(?P<id>[^/?]+).*?\bfullplayer=(?P<type>feature|preview)'
17 'url': 'https://www.gaia.com/video/connecting-universal-consciousness?fullplayer=feature',
21 'title': 'Connecting with Universal Consciousness',
22 'description': 'md5:844e209ad31b7d31345f5ed689e3df6f',
23 'upload_date': '20151116',
24 'timestamp': 1447707266,
29 'skip_download': True,
32 'url': 'https://www.gaia.com/video/connecting-universal-consciousness?fullplayer=preview',
36 'title': 'Connecting with Universal Consciousness',
37 'description': 'md5:844e209ad31b7d31345f5ed689e3df6f',
38 'upload_date': '20151116',
39 'timestamp': 1447707266,
44 'skip_download': True,
47 _NETRC_MACHINE
= 'gaia'
50 def _real_initialize(self
):
51 auth
= self
._get
_cookies
('https://www.gaia.com/').get('auth')
53 auth
= self
._parse
_json
(urllib
.parse
.unquote(auth
.value
), None, fatal
=False)
54 self
._jwt
= auth
.get('jwt')
56 def _perform_login(self
, username
, password
):
59 auth
= self
._download
_json
(
60 'https://auth.gaia.com/v1/login',
61 None, data
=urlencode_postdata({
65 if auth
.get('success') is False:
66 raise ExtractorError(', '.join(auth
['messages']), expected
=True)
67 self
._jwt
= auth
.get('jwt')
69 def _real_extract(self
, url
):
70 display_id
, vtype
= self
._match
_valid
_url
(url
).groups()
71 node_id
= self
._download
_json
(
72 'https://brooklyn.gaia.com/pathinfo', display_id
, query
={
73 'path': 'video/' + display_id
,
75 node
= self
._download
_json
(
76 'https://brooklyn.gaia.com/node/%d' % node_id
, node_id
)
78 media_id
= str(vdata
['nid'])
83 headers
= {'Authorization': 'Bearer ' + self
._jwt
}
84 media
= self
._download
_json
(
85 'https://brooklyn.gaia.com/media/' + media_id
,
86 media_id
, headers
=headers
)
87 formats
= self
._extract
_m
3u8_formats
(
88 media
['mediaUrls']['bcHLS'], media_id
, 'mp4')
91 text_tracks
= media
.get('textTracks', {})
92 for key
in ('captions', 'subtitles'):
93 for lang
, sub_url
in text_tracks
.get(key
, {}).items():
94 subtitles
.setdefault(lang
, []).append({
98 fivestar
= node
.get('fivestar', {})
99 fields
= node
.get('fields', {})
101 def get_field_value(key
, value_key
='value'):
102 return try_get(fields
, lambda x
: x
[key
][0][value_key
])
106 'display_id': display_id
,
109 'description': strip_or_none(get_field_value('body') or get_field_value('teaser')),
110 'timestamp': int_or_none(node
.get('created')),
111 'subtitles': subtitles
,
112 'duration': int_or_none(vdata
.get('duration')),
113 'like_count': int_or_none(try_get(fivestar
, lambda x
: x
['up_count']['value'])),
114 'dislike_count': int_or_none(try_get(fivestar
, lambda x
: x
['down_count']['value'])),
115 'comment_count': int_or_none(node
.get('comment_count')),
116 'series': try_get(node
, lambda x
: x
['series']['title'], str),
117 'season_number': int_or_none(get_field_value('season')),
118 'season_id': str_or_none(get_field_value('series_nid', 'nid')),
119 'episode_number': int_or_none(get_field_value('episode')),