]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gaia.py
f2eef3f4c362b3e4ab1f5ed126d7dfceb8ba32c6
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
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,
50 def _real_extract(self
, url
):
51 display_id
, vtype
= re
.search(self
._VALID
_URL
, url
).groups()
52 node_id
= self
._download
_json
(
53 'https://brooklyn.gaia.com/pathinfo', display_id
, query
={
54 'path': 'video/' + display_id
,
56 node
= self
._download
_json
(
57 'https://brooklyn.gaia.com/node/%d' % node_id
, node_id
)
59 media_id
= compat_str(vdata
['nid'])
62 media
= self
._download
_json
(
63 'https://brooklyn.gaia.com/media/' + media_id
, media_id
)
64 formats
= self
._extract
_m
3u8_formats
(
65 media
['mediaUrls']['bcHLS'], media_id
, 'mp4')
66 self
._sort
_formats
(formats
)
69 text_tracks
= media
.get('textTracks', {})
70 for key
in ('captions', 'subtitles'):
71 for lang
, sub_url
in text_tracks
.get(key
, {}).items():
72 subtitles
.setdefault(lang
, []).append({
76 fivestar
= node
.get('fivestar', {})
77 fields
= node
.get('fields', {})
79 def get_field_value(key
, value_key
='value'):
80 return try_get(fields
, lambda x
: x
[key
][0][value_key
])
84 'display_id': display_id
,
87 'description': strip_or_none(get_field_value('body') or get_field_value('teaser')),
88 'timestamp': int_or_none(node
.get('created')),
89 'subtitles': subtitles
,
90 'duration': int_or_none(vdata
.get('duration')),
91 'like_count': int_or_none(try_get(fivestar
, lambda x
: x
['up_count']['value'])),
92 'dislike_count': int_or_none(try_get(fivestar
, lambda x
: x
['down_count']['value'])),
93 'comment_count': int_or_none(node
.get('comment_count')),
94 'series': try_get(node
, lambda x
: x
['series']['title'], compat_str
),
95 'season_number': int_or_none(get_field_value('season')),
96 'season_id': str_or_none(get_field_value('series_nid', 'nid')),
97 'episode_number': int_or_none(get_field_value('episode')),