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.

60 lines
1.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .jwplatform import JWPlatformBaseIE
  4. from ..utils import (
  5. ExtractorError,
  6. js_to_json,
  7. )
  8. class OnDemandKoreaIE(JWPlatformBaseIE):
  9. _VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html'
  10. _TEST = {
  11. 'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html',
  12. 'info_dict': {
  13. 'id': 'ask-us-anything-e43',
  14. 'ext': 'mp4',
  15. 'title': 'Ask Us Anything : E43',
  16. 'thumbnail': r're:^https?://.*\.jpg$',
  17. },
  18. 'params': {
  19. 'skip_download': 'm3u8 download'
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id, fatal=False)
  25. if not webpage:
  26. # Page sometimes returns captcha page with HTTP 403
  27. raise ExtractorError(
  28. 'Unable to access page. You may have been blocked.',
  29. expected=True)
  30. if 'msg_block_01.png' in webpage:
  31. self.raise_geo_restricted(
  32. 'This content is not available in your region')
  33. if 'This video is only available to ODK PLUS members.' in webpage:
  34. raise ExtractorError(
  35. 'This video is only available to ODK PLUS members.',
  36. expected=True)
  37. title = self._og_search_title(webpage)
  38. jw_config = self._parse_json(
  39. self._search_regex(
  40. r'(?s)jwplayer\(([\'"])(?:(?!\1).)+\1\)\.setup\s*\((?P<options>.+?)\);',
  41. webpage, 'jw config', group='options'),
  42. video_id, transform_source=js_to_json)
  43. info = self._parse_jwplayer_data(
  44. jw_config, video_id, require_title=False, m3u8_id='hls',
  45. base_url=url)
  46. info.update({
  47. 'title': title,
  48. 'thumbnail': self._og_search_thumbnail(webpage),
  49. })
  50. return info