1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from .vimeo import VimeoIE
16 class RayWenderlichIE(InfoExtractor):
17 _VALID_URL = r'https?://videos\.raywenderlich\.com/courses/(?P<course_id>[^/]+)/lessons/(?P<id>\d+)'
20 'url': 'https://videos.raywenderlich.com/courses/105-testing-in-ios/lessons/1',
24 'title': 'Testing In iOS Episode 1: Introduction',
26 'uploader': 'Ray Wenderlich',
27 'uploader_id': 'user3304672',
31 'skip_download': True,
33 'add_ie': [VimeoIE.ie_key()],
34 'expected_warnings': ['HTTP Error 403: Forbidden'],
36 'url': 'https://videos.raywenderlich.com/courses/105-testing-in-ios/lessons/1',
38 'title': 'Testing in iOS',
39 'id': '105-testing-in-ios',
47 def _real_extract(self, url):
48 url, smuggled_data = unsmuggle_url(url, {})
50 mobj = re.match(self._VALID_URL, url)
51 course_id, lesson_id = mobj.group('course_id', 'id')
52 video_id = '%s/%s' % (course_id, lesson_id)
54 webpage = self._download_webpage(url, video_id)
56 no_playlist = self._downloader.params.get('noplaylist')
57 if no_playlist or smuggled_data.get('force_video', False):
60 'Downloading just video %s because of --no-playlist'
62 if '>Subscribe to unlock' in webpage:
64 'This content is only available for subscribers',
66 vimeo_id = self._search_regex(
67 r'data-vimeo-id=["\'](\d+)', webpage, 'video id')
68 return self.url_result(
69 VimeoIE._smuggle_referrer(
70 'https://player.vimeo.com/video/%s' % vimeo_id, url),
71 ie=VimeoIE.ie_key(), video_id=vimeo_id)
74 'Downloading playlist %s - add --no-playlist to just download video'
77 lesson_ids = set((lesson_id, ))
78 for lesson in re.findall(
79 r'(<a[^>]+\bclass=["\']lesson-link[^>]+>)', webpage):
80 attrs = extract_attributes(lesson)
83 lesson_url = attrs.get('href')
86 lesson_id = self._search_regex(
87 r'/lessons/(\d+)', lesson_url, 'lesson id', default=None)
90 lesson_ids.add(lesson_id)
93 for lesson_id in sorted(lesson_ids):
94 entries.append(self.url_result(
95 smuggle_url(urljoin(url, lesson_id), {'force_video': True}),
96 ie=RayWenderlichIE.ie_key()))
98 title = self._search_regex(
99 r'class=["\']course-title[^>]+>([^<]+)', webpage, 'course title',
102 return self.playlist_result(entries, course_id, title)