[roxwel] Modernize

This commit is contained in:
Jaime Marquínez Ferrándiz 2014-03-29 14:44:36 +01:00
parent 2583a0308b
commit 986f56736b

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals
import re import re
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import unified_strdate, determine_ext from ..utils import unified_strdate, determine_ext
@ -9,41 +10,44 @@ class RoxwelIE(InfoExtractor):
_VALID_URL = r'https?://www\.roxwel\.com/player/(?P<filename>.+?)(\.|\?|$)' _VALID_URL = r'https?://www\.roxwel\.com/player/(?P<filename>.+?)(\.|\?|$)'
_TEST = { _TEST = {
u'url': u'http://www.roxwel.com/player/passionpittakeawalklive.html', 'url': 'http://www.roxwel.com/player/passionpittakeawalklive.html',
u'file': u'passionpittakeawalklive.flv', 'info_dict': {
u'md5': u'd9dea8360a1e7d485d2206db7fe13035', 'id': 'passionpittakeawalklive',
u'info_dict': { 'ext': 'flv',
u'title': u'Take A Walk (live)', 'title': 'Take A Walk (live)',
u'uploader': u'Passion Pit', 'uploader': 'Passion Pit',
u'description': u'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ', 'uploader_id': 'passionpit',
'upload_date': '20120928',
'description': 'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ',
}, },
u'skip': u'Requires rtmpdump', 'params': {
# rtmp download
'skip_download': True,
}
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
filename = mobj.group('filename') filename = mobj.group('filename')
info_url = 'http://www.roxwel.com/api/videos/%s' % filename info_url = 'http://www.roxwel.com/api/videos/%s' % filename
info_page = self._download_webpage(info_url, filename, info = self._download_json(info_url, filename)
u'Downloading video info')
self.report_extraction(filename)
info = json.loads(info_page)
rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')]) rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')])
best_rate = rtmp_rates[-1] best_rate = rtmp_rates[-1]
url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate) url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate)
rtmp_url = self._download_webpage(url_page_url, filename, u'Downloading video url') rtmp_url = self._download_webpage(url_page_url, filename, 'Downloading video url')
ext = determine_ext(rtmp_url) ext = determine_ext(rtmp_url)
if ext == 'f4v': if ext == 'f4v':
rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename) rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename)
return {'id': filename, return {
'title': info['title'], 'id': filename,
'url': rtmp_url, 'title': info['title'],
'ext': 'flv', 'url': rtmp_url,
'description': info['description'], 'ext': 'flv',
'thumbnail': info.get('player_image_url') or info.get('image_url_large'), 'description': info['description'],
'uploader': info['artist'], 'thumbnail': info.get('player_image_url') or info.get('image_url_large'),
'uploader_id': info['artistname'], 'uploader': info['artist'],
'upload_date': unified_strdate(info['dbdate']), 'uploader_id': info['artistname'],
} 'upload_date': unified_strdate(info['dbdate']),
}