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