]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/freshlive.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
14 class FreshLiveIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://freshlive\.tv/[^/]+/(?P<id>\d+)'
17 'url': 'https://freshlive.tv/satotv/74712',
18 'md5': '9f0cf5516979c4454ce982df3d97f352',
24 'thumbnail': r
're:^https?://.*\.jpg$',
26 'timestamp': 1483619655,
27 'upload_date': '20170105',
29 'uploader_id': 'satotv',
36 def _real_extract(self
, url
):
37 video_id
= self
._match
_id
(url
)
39 webpage
= self
._download
_webpage
(url
, video_id
)
41 options
= self
._parse
_json
(
43 r
'window\.__CONTEXT__\s*=\s*({.+?});\s*</script>',
44 webpage
, 'initial context'),
47 info
= options
['context']['dispatcher']['stores']['ProgramStore']['programs'][video_id
]
51 if info
.get('status') == 'upcoming':
52 raise ExtractorError('Stream %s is upcoming' % video_id
, expected
=True)
54 stream_url
= info
.get('liveStreamUrl') or info
['archiveStreamUrl']
56 is_live
= info
.get('liveStreamUrl') is not None
58 formats
= self
._extract
_m
3u8_formats
(
59 stream_url
, video_id
, 'mp4',
60 'm3u8_native', m3u8_id
='hls')
63 title
= self
._live
_title
(title
)
69 'description': info
.get('description'),
70 'thumbnail': info
.get('thumbnailUrl'),
71 'duration': int_or_none(info
.get('airTime')),
72 'timestamp': unified_timestamp(info
.get('createdAt')),
74 info
, lambda x
: x
['channel']['title'], compat_str
),
75 'uploader_id': try_get(
76 info
, lambda x
: x
['channel']['code'], compat_str
),
77 'uploader_url': try_get(
78 info
, lambda x
: x
['channel']['permalink'], compat_str
),
79 'view_count': int_or_none(info
.get('viewCount')),
80 'comment_count': int_or_none(info
.get('commentCount')),
81 'tags': info
.get('tags', []),