You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

  1. import re
  2. import json
  3. from .common import InfoExtractor
  4. from ..utils import unified_strdate, determine_ext
  5. class RoxwelIE(InfoExtractor):
  6. _VALID_URL = r'https?://www\.roxwel\.com/player/(?P<filename>.+?)(\.|\?|$)'
  7. _TEST = {
  8. u'url': u'http://www.roxwel.com/player/passionpittakeawalklive.html',
  9. u'file': u'passionpittakeawalklive.flv',
  10. u'md5': u'd9dea8360a1e7d485d2206db7fe13035',
  11. u'info_dict': {
  12. u'title': u'Take A Walk (live)',
  13. u'uploader': u'Passion Pit',
  14. u'description': u'Passion Pit performs "Take A Walk\" live at The Backyard in Austin, Texas. ',
  15. },
  16. u'skip': u'Requires rtmpdump',
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. filename = mobj.group('filename')
  21. info_url = 'http://www.roxwel.com/api/videos/%s' % filename
  22. info_page = self._download_webpage(info_url, filename,
  23. u'Downloading video info')
  24. self.report_extraction(filename)
  25. info = json.loads(info_page)
  26. rtmp_rates = sorted([int(r.replace('flv_', '')) for r in info['media_rates'] if r.startswith('flv_')])
  27. best_rate = rtmp_rates[-1]
  28. url_page_url = 'http://roxwel.com/pl_one_time.php?filename=%s&quality=%s' % (filename, best_rate)
  29. rtmp_url = self._download_webpage(url_page_url, filename, u'Downloading video url')
  30. ext = determine_ext(rtmp_url)
  31. if ext == 'f4v':
  32. rtmp_url = rtmp_url.replace(filename, 'mp4:%s' % filename)
  33. return {'id': filename,
  34. 'title': info['title'],
  35. 'url': rtmp_url,
  36. 'ext': 'flv',
  37. 'description': info['description'],
  38. 'thumbnail': info.get('player_image_url') or info.get('image_url_large'),
  39. 'uploader': info['artist'],
  40. 'uploader_id': info['artistname'],
  41. 'upload_date': unified_strdate(info['dbdate']),
  42. }