logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

ondemandkorea.py (2036B)


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