]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/freshlive.py
a90f9156c694be3395dd505c6015f595fdb797b5
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
, ext
='mp4',
60 entry_protocol
='m3u8' if is_live
else 'm3u8_native',
64 title
= self
._live
_title
(title
)
70 'description': info
.get('description'),
71 'thumbnail': info
.get('thumbnailUrl'),
72 'duration': int_or_none(info
.get('airTime')),
73 'timestamp': unified_timestamp(info
.get('createdAt')),
75 info
, lambda x
: x
['channel']['title'], compat_str
),
76 'uploader_id': try_get(
77 info
, lambda x
: x
['channel']['code'], compat_str
),
78 'uploader_url': try_get(
79 info
, lambda x
: x
['channel']['permalink'], compat_str
),
80 'view_count': int_or_none(info
.get('viewCount')),
81 'comment_count': int_or_none(info
.get('commentCount')),
82 'tags': info
.get('tags', []),