]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/roxwel.py
[afreecatv] Support password-protected livestreams (#2738)
[yt-dlp.git] / yt_dlp / extractor / roxwel.py
1 from __future__ import unicode_literals
2
3
4 from .common import InfoExtractor
5 from ..utils import unified_strdate, determine_ext
6
7
8 class RoxwelIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?roxwel\.com/player/(?P<filename>.+?)(\.|\?|$)'
10
11 _TEST = {
12 'url': 'http://www.roxwel.com/player/passionpittakeawalklive.html',
13 'info_dict': {
14 'id': 'passionpittakeawalklive',
15 'ext': 'flv',
16 'title': 'Take A Walk (live)',
17 'uploader': 'Passion Pit',
18 'uploader_id': 'passionpit',
19 'upload_date': '20120928',
20 'description': 'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ',
21 },
22 'params': {
23 # rtmp download
24 'skip_download': True,
25 }
26 }
27
28 def _real_extract(self, url):
29 mobj = self._match_valid_url(url)
30 filename = mobj.group('filename')
31 info_url = 'http://www.roxwel.com/api/videos/%s' % filename
32 info = self._download_json(info_url, filename)
33
34 rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')])
35 best_rate = rtmp_rates[-1]
36 url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate)
37 rtmp_url = self._download_webpage(url_page_url, filename, 'Downloading video url')
38 ext = determine_ext(rtmp_url)
39 if ext == 'f4v':
40 rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename)
41
42 return {
43 'id': filename,
44 'title': info['title'],
45 'url': rtmp_url,
46 'ext': 'flv',
47 'description': info['description'],
48 'thumbnail': info.get('player_image_url') or info.get('image_url_large'),
49 'uploader': info['artist'],
50 'uploader_id': info['artistname'],
51 'upload_date': unified_strdate(info['dbdate']),
52 }