aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/godtv.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-06-09 21:29:41 +0700
committerSergey M․ <dstftw@gmail.com>2016-06-09 21:29:41 +0700
commitc0fed3bda50f77d063f3817cfbc3d8b81c18afa6 (patch)
treec8864a0a725468097803930f4216dbd3cc737033 /youtube_dl/extractor/godtv.py
parentbb1e44cc8ee7937422fb5635f3431feb6d5fd918 (diff)
[godtv] Improve and add support for playlists (Closes #9608)
Diffstat (limited to 'youtube_dl/extractor/godtv.py')
-rw-r--r--youtube_dl/extractor/godtv.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/youtube_dl/extractor/godtv.py b/youtube_dl/extractor/godtv.py
index 50f093ace..78d638cf0 100644
--- a/youtube_dl/extractor/godtv.py
+++ b/youtube_dl/extractor/godtv.py
@@ -1,13 +1,13 @@
-# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from .ooyala import OoyalaIE
+from ..utils import js_to_json
class GodTVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?god\.tv(?:/[^/]+)+/(?P<id>[^/?#&]+)'
- _TEST = {
+ _TESTS = [{
'url': 'http://god.tv/jesus-image/video/jesus-conference-2016/randy-needham',
'info_dict': {
'id': 'lpd3g2MzE6D1g8zFAKz8AGpxWcpu6o_3',
@@ -18,12 +18,40 @@ class GodTVIE(InfoExtractor):
'params': {
'skip_download': True,
}
- }
+ }, {
+ 'url': 'http://god.tv/playlist/bible-study',
+ 'info_dict': {
+ 'id': 'bible-study',
+ },
+ 'playlist_mincount': 37,
+ }]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
- ooyala_id = self._search_regex(r'"content_id"\s*:\s*"([\w-]{32})"', webpage, display_id)
+
+ settings = self._parse_json(
+ self._search_regex(
+ r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);',
+ webpage, 'settings', default='{}'),
+ display_id, transform_source=js_to_json, fatal=False)
+
+ ooyala_id = None
+
+ if settings:
+ playlist = settings.get('playlist')
+ if playlist and isinstance(playlist, list):
+ entries = [
+ OoyalaIE._build_url_result(video['content_id'])
+ for video in playlist if video.get('content_id')]
+ if entries:
+ return self.playlist_result(entries, display_id)
+ ooyala_id = settings.get('ooyala', {}).get('content_id')
+
+ if not ooyala_id:
+ ooyala_id = self._search_regex(
+ r'["\']content_id["\']\s*:\s*(["\'])(?P<id>[\w-]+)\1',
+ webpage, 'ooyala id', group='id')
return OoyalaIE._build_url_result(ooyala_id)