]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/beampro.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
15 class BeamProLiveIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:\w+\.)?beam\.pro/(?P<id>[^/?#&]+)'
18 _RATINGS
= {'family': 0, 'teen': 13, '18+': 18}
20 'url': 'http://www.beam.pro/niterhayven',
24 'title': 'Introducing The Witcher 3 // The Grind Starts Now!',
25 'description': 'md5:0b161ac080f15fe05d18a07adb44a74d',
26 'thumbnail': r
're:https://.*\.jpg$',
27 'timestamp': 1483477281,
28 'upload_date': '20170103',
29 'uploader': 'niterhayven',
30 'uploader_id': '373396',
35 'skip': 'niterhayven is offline',
37 'skip_download': True,
41 def _real_extract(self
, url
):
42 channel_name
= self
._match
_id
(url
)
44 chan
= self
._download
_json
(
45 'https://beam.pro/api/v1/channels/%s' % channel_name
, channel_name
)
47 if chan
.get('online') is False:
49 '{0} is offline'.format(channel_name
), expected
=True)
51 channel_id
= chan
['id']
53 formats
= self
._extract
_m
3u8_formats
(
54 'https://beam.pro/api/v1/channels/%s/manifest.m3u8' % channel_id
,
55 channel_name
, ext
='mp4', m3u8_id
='hls', fatal
=False)
56 self
._sort
_formats
(formats
)
58 user_id
= chan
.get('userId') or try_get(chan
, lambda x
: x
['user']['id'])
61 'id': compat_str(chan
.get('id') or channel_name
),
62 'title': self
._live
_title
(chan
.get('name') or channel_name
),
63 'description': clean_html(chan
.get('description')),
64 'thumbnail': try_get(chan
, lambda x
: x
['thumbnail']['url'], compat_str
),
65 'timestamp': parse_iso8601(chan
.get('updatedAt')),
66 'uploader': chan
.get('token') or try_get(
67 chan
, lambda x
: x
['user']['username'], compat_str
),
68 'uploader_id': compat_str(user_id
) if user_id
else None,
69 'age_limit': self
._RATINGS
.get(chan
.get('audience')),
71 'view_count': int_or_none(chan
.get('viewersTotal')),