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.

66 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from .ooyala import OoyalaIE
  4. from ..utils import js_to_json
  5. class GodTVIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?god\.tv(?:/[^/]+)*/(?P<id>[^/?#&]+)'
  7. _TESTS = [{
  8. 'url': 'http://god.tv/jesus-image/video/jesus-conference-2016/randy-needham',
  9. 'info_dict': {
  10. 'id': 'lpd3g2MzE6D1g8zFAKz8AGpxWcpu6o_3',
  11. 'ext': 'mp4',
  12. 'title': 'Randy Needham',
  13. 'duration': 3615.08,
  14. },
  15. 'params': {
  16. 'skip_download': True,
  17. }
  18. }, {
  19. 'url': 'http://god.tv/playlist/bible-study',
  20. 'info_dict': {
  21. 'id': 'bible-study',
  22. },
  23. 'playlist_mincount': 37,
  24. }, {
  25. 'url': 'http://god.tv/node/15097',
  26. 'only_matching': True,
  27. }, {
  28. 'url': 'http://god.tv/live/africa',
  29. 'only_matching': True,
  30. }, {
  31. 'url': 'http://god.tv/liveevents',
  32. 'only_matching': True,
  33. }]
  34. def _real_extract(self, url):
  35. display_id = self._match_id(url)
  36. webpage = self._download_webpage(url, display_id)
  37. settings = self._parse_json(
  38. self._search_regex(
  39. r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
  40. webpage, 'settings', default='{}'),
  41. display_id, transform_source=js_to_json, fatal=False)
  42. ooyala_id = None
  43. if settings:
  44. playlist = settings.get('playlist')
  45. if playlist and isinstance(playlist, list):
  46. entries = [
  47. OoyalaIE._build_url_result(video['content_id'])
  48. for video in playlist if video.get('content_id')]
  49. if entries:
  50. return self.playlist_result(entries, display_id)
  51. ooyala_id = settings.get('ooyala', {}).get('content_id')
  52. if not ooyala_id:
  53. ooyala_id = self._search_regex(
  54. r'["\']content_id["\']\s*:\s*(["\'])(?P<id>[\w-]+)\1',
  55. webpage, 'ooyala id', group='id')
  56. return OoyalaIE._build_url_result(ooyala_id)