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.

53 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .jwplatform import JWPlatformBaseIE
  5. from ..utils import (
  6. js_to_json,
  7. get_element_by_class,
  8. unified_strdate,
  9. )
  10. class RudoIE(JWPlatformBaseIE):
  11. _VALID_URL = r'https?://rudo\.video/vod/(?P<id>[0-9a-zA-Z]+)'
  12. _TEST = {
  13. 'url': 'http://rudo.video/vod/oTzw0MGnyG',
  14. 'md5': '2a03a5b32dd90a04c83b6d391cf7b415',
  15. 'info_dict': {
  16. 'id': 'oTzw0MGnyG',
  17. 'ext': 'mp4',
  18. 'title': 'Comentario Tomás Mosciatti',
  19. 'upload_date': '20160617',
  20. },
  21. }
  22. @classmethod
  23. def _extract_url(self, webpage):
  24. mobj = re.search(
  25. '<iframe[^>]+src=(?P<q1>[\'"])(?P<url>(?:https?:)?//rudo\.video/vod/[0-9a-zA-Z]+)(?P=q1)',
  26. webpage)
  27. if mobj:
  28. return mobj.group('url')
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id, encoding='iso-8859-1')
  32. jwplayer_data = self._parse_json(self._search_regex(
  33. r'(?s)playerInstance\.setup\(({.+?})\)', webpage, 'jwplayer data'), video_id,
  34. transform_source=lambda s: js_to_json(re.sub(r'encodeURI\([^)]+\)', '""', s)))
  35. info_dict = self._parse_jwplayer_data(
  36. jwplayer_data, video_id, require_title=False, m3u8_id='hls', mpd_id='dash')
  37. info_dict.update({
  38. 'title': self._og_search_title(webpage),
  39. 'upload_date': unified_strdate(get_element_by_class('date', webpage)),
  40. })
  41. return info_dict