]>
Commit | Line | Data |
---|---|---|
add96eb9 | 1 | import urllib.parse |
ac668111 | 2 | |
38ad119f | 3 | from .common import InfoExtractor |
ac668111 | 4 | from ..utils import ExtractorError |
38ad119f PH |
5 | |
6 | ||
7 | class ScreencastIE(InfoExtractor): | |
83cedc1c | 8 | _VALID_URL = r'https?://(?:www\.)?screencast\.com/t/(?P<id>[a-zA-Z0-9]+)' |
40c696e5 | 9 | _TESTS = [{ |
38ad119f PH |
10 | 'url': 'http://www.screencast.com/t/3ZEjQXlT', |
11 | 'md5': '917df1c13798a3e96211dd1561fded83', | |
12 | 'info_dict': { | |
13 | 'id': '3ZEjQXlT', | |
14 | 'ext': 'm4v', | |
15 | 'title': 'Color Measurement with Ocean Optics Spectrometers', | |
16 | 'description': 'md5:240369cde69d8bed61349a199c5fb153', | |
ec85ded8 | 17 | 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$', |
add96eb9 | 18 | }, |
40c696e5 PH |
19 | }, { |
20 | 'url': 'http://www.screencast.com/t/V2uXehPJa1ZI', | |
21 | 'md5': 'e8e4b375a7660a9e7e35c33973410d34', | |
22 | 'info_dict': { | |
23 | 'id': 'V2uXehPJa1ZI', | |
24 | 'ext': 'mov', | |
25 | 'title': 'The Amadeus Spectrometer', | |
26 | 'description': 're:^In this video, our friends at.*To learn more about Amadeus, visit', | |
ec85ded8 | 27 | 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$', |
add96eb9 | 28 | }, |
40c696e5 | 29 | }, { |
81de73e5 | 30 | 'url': 'http://www.screencast.com/t/aAB3iowa', |
40c696e5 PH |
31 | 'md5': 'dedb2734ed00c9755761ccaee88527cd', |
32 | 'info_dict': { | |
33 | 'id': 'aAB3iowa', | |
34 | 'ext': 'mp4', | |
35 | 'title': 'Google Earth Export', | |
36 | 'description': 'Provides a demo of a CommunityViz export to Google Earth, one of the 3D viewing options.', | |
ec85ded8 | 37 | 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$', |
add96eb9 | 38 | }, |
c961a0e6 S |
39 | }, { |
40 | 'url': 'http://www.screencast.com/t/X3ddTrYh', | |
41 | 'md5': '669ee55ff9c51988b4ebc0877cc8b159', | |
42 | 'info_dict': { | |
43 | 'id': 'X3ddTrYh', | |
44 | 'ext': 'wmv', | |
45 | 'title': 'Toolkit 6 User Group Webinar (2014-03-04) - Default Judgment and First Impression', | |
46 | 'description': 'md5:7b9f393bc92af02326a5c5889639eab0', | |
ec85ded8 | 47 | 'thumbnail': r're:^https?://.*\.(?:gif|jpg)$', |
add96eb9 | 48 | }, |
81de73e5 S |
49 | }, { |
50 | 'url': 'http://screencast.com/t/aAB3iowa', | |
51 | 'only_matching': True, | |
52 | }] | |
38ad119f PH |
53 | |
54 | def _real_extract(self, url): | |
1cc79574 | 55 | video_id = self._match_id(url) |
38ad119f PH |
56 | webpage = self._download_webpage(url, video_id) |
57 | ||
40c696e5 PH |
58 | video_url = self._html_search_regex( |
59 | r'<embed name="Video".*?src="([^"]+)"', webpage, | |
60 | 'QuickTime embed', default=None) | |
61 | ||
62 | if video_url is None: | |
63 | flash_vars_s = self._html_search_regex( | |
64 | r'<param name="flashVars" value="([^"]+)"', webpage, 'flash vars', | |
65 | default=None) | |
c961a0e6 S |
66 | if not flash_vars_s: |
67 | flash_vars_s = self._html_search_regex( | |
68 | r'<param name="initParams" value="([^"]+)"', webpage, 'flash vars', | |
69 | default=None) | |
70 | if flash_vars_s: | |
71 | flash_vars_s = flash_vars_s.replace(',', '&') | |
40c696e5 | 72 | if flash_vars_s: |
add96eb9 | 73 | flash_vars = urllib.parse.parse_qs(flash_vars_s) |
74 | video_url_raw = urllib.parse.quote( | |
40c696e5 PH |
75 | flash_vars['content'][0]) |
76 | video_url = video_url_raw.replace('http%3A', 'http:') | |
77 | ||
78 | if video_url is None: | |
79 | video_meta = self._html_search_meta( | |
80 | 'og:video', webpage, default=None) | |
81 | if video_meta: | |
82 | video_url = self._search_regex( | |
83 | r'src=(.*?)(?:$|&)', video_meta, | |
84 | 'meta tag video URL', default=None) | |
85 | ||
1fafb329 | 86 | if video_url is None: |
87 | video_url = self._html_search_regex( | |
a1d1c636 S |
88 | r'MediaContentUrl["\']\s*:(["\'])(?P<url>(?:(?!\1).)+)\1', |
89 | webpage, 'video url', default=None, group='url') | |
1fafb329 | 90 | |
91 | if video_url is None: | |
92 | video_url = self._html_search_meta( | |
93 | 'og:video', webpage, default=None) | |
94 | ||
40c696e5 PH |
95 | if video_url is None: |
96 | raise ExtractorError('Cannot find video') | |
38ad119f | 97 | |
40c696e5 PH |
98 | title = self._og_search_title(webpage, default=None) |
99 | if title is None: | |
100 | title = self._html_search_regex( | |
75d572e9 S |
101 | [r'<b>Title:</b> ([^<]+)</div>', |
102 | r'class="tabSeperator">></span><span class="tabText">(.+?)<', | |
103 | r'<title>([^<]+)</title>'], | |
40c696e5 PH |
104 | webpage, 'title') |
105 | thumbnail = self._og_search_thumbnail(webpage) | |
106 | description = self._og_search_description(webpage, default=None) | |
107 | if description is None: | |
108 | description = self._html_search_meta('description', webpage) | |
38ad119f PH |
109 | |
110 | return { | |
111 | 'id': video_id, | |
112 | 'url': video_url, | |
113 | 'title': title, | |
114 | 'description': description, | |
115 | 'thumbnail': thumbnail, | |
116 | } |