4 from .common
import InfoExtractor
13 class CamdemyIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?camdemy\.com/media/(?P<id>\d+)'
17 'url': 'http://www.camdemy.com/media/5181/',
18 'md5': '5a5562b6a98b37873119102e052e311b',
22 'title': 'Ch1-1 Introduction, Signals (02-23-2012)',
23 'thumbnail': r
're:^https?://.*\.jpg$',
24 'creator': 'ss11spring',
26 'upload_date': '20130114',
30 # With non-empty description
31 # webpage returns "No permission or not login"
32 'url': 'http://www.camdemy.com/media/13885',
33 'md5': '4576a3bb2581f86c61044822adbd1249',
37 'title': 'EverCam + Camdemy QuickStart',
38 'thumbnail': r
're:^https?://.*\.jpg$',
39 'description': 'md5:2a9f989c2b153a2342acee579c6e7db6',
44 # External source (YouTube)
45 'url': 'http://www.camdemy.com/media/14842',
49 'title': 'Excel 2013 Tutorial - How to add Password Protection',
50 'description': 'Excel 2013 Tutorial for Beginners - How to add Password Protection',
51 'upload_date': '20130211',
52 'uploader': 'Hun Kim',
53 'uploader_id': 'hunkimtutorials',
56 'skip_download': True,
60 def _real_extract(self
, url
):
61 video_id
= self
._match
_id
(url
)
63 webpage
= self
._download
_webpage
(url
, video_id
)
65 src_from
= self
._html
_search
_regex
(
66 r
"class=['\"]srcFrom
['\"][^>]*>Sources?(?:\s+from)?\s*:\s*<a[^>]+(?:href|title)=(['\"])(?P
<url
>(?
:(?
!\
1).)+)\
1",
67 webpage, 'external source', default=None, group='url')
69 return self.url_result(src_from)
71 oembed_obj = self._download_json(
72 'http://www.camdemy.com/oembed/?format=json&url=' + url, video_id)
74 title = oembed_obj['title']
75 thumb_url = oembed_obj['thumbnail_url']
76 video_folder = urllib.parse.urljoin(thumb_url, 'video/')
77 file_list_doc = self._download_xml(
78 urllib.parse.urljoin(video_folder, 'fileList.xml'),
79 video_id, 'Downloading filelist XML')
80 file_name = file_list_doc.find('./video/item/fileName').text
81 video_url = urllib.parse.urljoin(video_folder, file_name)
83 # Some URLs return "No permission
or not login
" in a webpage despite being
84 # freely available via oembed JSON URL (e.g. http://www.camdemy.com/media/13885)
85 upload_date = unified_strdate(self._search_regex(
86 r'>published on ([^<]+)<', webpage,
87 'upload date', default=None))
88 view_count = str_to_int(self._search_regex(
89 r'role=["\']viewCnt
["\'][^>]*>([\d,.]+) views',
90 webpage, 'view count', default=None))
91 description = self._html_search_meta(
92 'description', webpage, default=None) or clean_html(
93 oembed_obj.get('description'))
99 'thumbnail': thumb_url,
100 'description': description,
101 'creator': oembed_obj.get('author_name'),
102 'duration': parse_duration(oembed_obj.get('duration')),
103 'upload_date': upload_date,
104 'view_count': view_count,
108 class CamdemyFolderIE(InfoExtractor):
109 _VALID_URL = r'https?://(?:www\.)?camdemy\.com/folder/(?P<id>\d+)'
111 # links with trailing slash
112 'url': 'http://www.camdemy.com/folder/450',
115 'title': '信號與系統 2012 & 2011 (Signals and Systems)',
117 'playlist_mincount': 145,
119 # links without trailing slash
121 'url': 'http://www.camdemy.com/folder/853',
124 'title': '科學計算 - 使用 Matlab',
126 'playlist_mincount': 20,
128 # with displayMode parameter. For testing the codes to add parameters
129 'url': 'http://www.camdemy.com/folder/853/?displayMode=defaultOrderByOrg',
132 'title': '科學計算 - 使用 Matlab',
134 'playlist_mincount': 20,
137 def _real_extract(self, url):
138 folder_id = self._match_id(url)
140 # Add displayMode=list so that all links are displayed in a single page
141 parsed_url = list(urllib.parse.urlparse(url))
142 query = dict(urllib.parse.parse_qsl(parsed_url[4]))
143 query.update({'displayMode': 'list'})
144 parsed_url[4] = urllib.parse.urlencode(query)
145 final_url = urllib.parse.urlunparse(parsed_url)
147 page = self._download_webpage(final_url, folder_id)
148 matches = re.findall(r"href
='(/media/\d+/?)'", page)
150 entries = [self.url_result('http://www.camdemy.com' + media_path)
151 for media_path in matches]
153 folder_title = self._html_search_meta('keywords', page)
155 return self.playlist_result(entries, folder_id, folder_title)