1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from .vimeo import VimeoIE
17 class RayWenderlichIE(InfoExtractor):
18 _VALID_URL = r'https?://videos\.raywenderlich\.com/courses/(?P<course_id>[^/]+)/lessons/(?P<id>\d+)'
21 'url': 'https://videos.raywenderlich.com/courses/105-testing-in-ios/lessons/1',
25 'title': 'Testing In iOS Episode 1: Introduction',
27 'uploader': 'Ray Wenderlich',
28 'uploader_id': 'user3304672',
32 'skip_download': True,
34 'add_ie': [VimeoIE.ie_key()],
35 'expected_warnings': ['HTTP Error 403: Forbidden'],
37 'url': 'https://videos.raywenderlich.com/courses/105-testing-in-ios/lessons/1',
39 'title': 'Testing in iOS',
40 'id': '105-testing-in-ios',
48 def _real_extract(self, url):
49 url, smuggled_data = unsmuggle_url(url, {})
51 mobj = re.match(self._VALID_URL, url)
52 course_id, lesson_id = mobj.group('course_id', 'id')
53 video_id = '%s/%s' % (course_id, lesson_id)
55 webpage = self._download_webpage(url, video_id)
57 no_playlist = self._downloader.params.get('noplaylist')
58 if no_playlist or smuggled_data.get('force_video', False):
61 'Downloading just video %s because of --no-playlist'
63 if '>Subscribe to unlock' in webpage:
65 'This content is only available for subscribers',
67 vimeo_id = self._search_regex(
68 r'data-vimeo-id=["\'](\d+)', webpage, 'video id')
69 return self.url_result(
70 VimeoIE._smuggle_referrer(
71 'https://player.vimeo.com/video/%s' % vimeo_id, url),
72 ie=VimeoIE.ie_key(), video_id=vimeo_id)
75 'Downloading playlist %s - add --no-playlist to just download video'
78 lesson_ids = [lesson_id]
79 for lesson in re.findall(
80 r'(<a[^>]+\bclass=["\']lesson-link[^>]+>)', webpage):
81 attrs = extract_attributes(lesson)
84 lesson_url = attrs.get('href')
87 lesson_id = self._search_regex(
88 r'/lessons/(\d+)', lesson_url, 'lesson id', default=None)
91 lesson_ids.append(lesson_id)
94 for lesson_id in orderedSet(lesson_ids):
95 entries.append(self.url_result(
96 smuggle_url(urljoin(url, lesson_id), {'force_video': True}),
97 ie=RayWenderlichIE.ie_key()))
99 title = self._search_regex(
100 r'class=["\']course-title[^>]+>([^<]+)', webpage, 'course title',
103 return self.playlist_result(entries, course_id, title)