]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/roxwel.py
[youtube] Do not break upon unknown formats
[youtube-dl] / youtube_dl / extractor / roxwel.py
1 import re
2 import json
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         u'url': u'http://www.roxwel.com/player/passionpittakeawalklive.html',
13         u'file': u'passionpittakeawalklive.flv',
14         u'md5': u'd9dea8360a1e7d485d2206db7fe13035',
15         u'info_dict': {
16             u'title': u'Take A Walk (live)',
17             u'uploader': u'Passion Pit',
18             u'description': u'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ',
19         },
20         u'skip': u'Requires rtmpdump',
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         filename = mobj.group('filename')
26         info_url = 'http://www.roxwel.com/api/videos/%s' % filename
27         info_page = self._download_webpage(info_url, filename,
28                                            u'Downloading video info')
29
30         self.report_extraction(filename)
31         info = json.loads(info_page)
32         rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')])
33         best_rate = rtmp_rates[-1]
34         url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate)
35         rtmp_url = self._download_webpage(url_page_url, filename, u'Downloading video url')
36         ext = determine_ext(rtmp_url)
37         if ext == 'f4v':
38             rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename)
39
40         return {'id': filename,
41                 'title': info['title'],
42                 'url': rtmp_url,
43                 'ext': 'flv',
44                 'description': info['description'],
45                 'thumbnail': info.get('player_image_url') or info.get('image_url_large'),
46                 'uploader': info['artist'],
47                 'uploader_id': info['artistname'],
48                 'upload_date': unified_strdate(info['dbdate']),
49                 }