]>
Commit | Line | Data |
---|---|---|
a229909f | 1 | from .common import InfoExtractor |
e897bd82 | 2 | from ..utils import ExtractorError, unified_strdate |
a229909f NJ |
3 | |
4 | ||
5 | class JoveIE(InfoExtractor): | |
6 | _VALID_URL = r'https?://(?:www\.)?jove\.com/video/(?P<id>[0-9]+)' | |
7 | _CHAPTERS_URL = 'http://www.jove.com/video-chapters?videoid={video_id:}' | |
fe556f1b S |
8 | _TESTS = [ |
9 | { | |
10 | 'url': 'http://www.jove.com/video/2744/electrode-positioning-montage-transcranial-direct-current', | |
11 | 'md5': '93723888d82dbd6ba8b3d7d0cd65dd2b', | |
12 | 'info_dict': { | |
13 | 'id': '2744', | |
14 | 'ext': 'mp4', | |
15 | 'title': 'Electrode Positioning and Montage in Transcranial Direct Current Stimulation', | |
16 | 'description': 'md5:015dd4509649c0908bc27f049e0262c6', | |
ec85ded8 | 17 | 'thumbnail': r're:^https?://.*\.png$', |
fe556f1b | 18 | 'upload_date': '20110523', |
add96eb9 | 19 | }, |
fe556f1b S |
20 | }, |
21 | { | |
22 | 'url': 'http://www.jove.com/video/51796/culturing-caenorhabditis-elegans-axenic-liquid-media-creation', | |
23 | 'md5': '914aeb356f416811d911996434811beb', | |
24 | 'info_dict': { | |
25 | 'id': '51796', | |
26 | 'ext': 'mp4', | |
27 | 'title': 'Culturing Caenorhabditis elegans in Axenic Liquid Media and Creation of Transgenic Worms by Microparticle Bombardment', | |
28 | 'description': 'md5:35ff029261900583970c4023b70f1dc9', | |
ec85ded8 | 29 | 'thumbnail': r're:^https?://.*\.png$', |
fe556f1b | 30 | 'upload_date': '20140802', |
add96eb9 | 31 | }, |
fe556f1b S |
32 | }, |
33 | ||
34 | ] | |
a229909f NJ |
35 | |
36 | def _real_extract(self, url): | |
5ad28e7f | 37 | mobj = self._match_valid_url(url) |
a229909f NJ |
38 | video_id = mobj.group('id') |
39 | ||
40 | webpage = self._download_webpage(url, video_id) | |
a229909f | 41 | |
a229909f NJ |
42 | chapters_id = self._html_search_regex( |
43 | r'/video-chapters\?videoid=([0-9]+)', webpage, 'chapters id') | |
fe556f1b | 44 | |
a229909f NJ |
45 | chapters_xml = self._download_xml( |
46 | self._CHAPTERS_URL.format(video_id=chapters_id), | |
fe556f1b S |
47 | video_id, note='Downloading chapters XML', |
48 | errnote='Failed to download chapters XML') | |
49 | ||
a229909f NJ |
50 | video_url = chapters_xml.attrib.get('video') |
51 | if not video_url: | |
52 | raise ExtractorError('Failed to get the video URL') | |
53 | ||
fe556f1b S |
54 | title = self._html_search_meta('citation_title', webpage, 'title') |
55 | thumbnail = self._og_search_thumbnail(webpage) | |
56 | description = self._html_search_regex( | |
57 | r'<div id="section_body_summary"><p class="jove_content">(.+?)</p>', | |
58 | webpage, 'description', fatal=False) | |
59 | publish_date = unified_strdate(self._html_search_meta( | |
60 | 'citation_publication_date', webpage, 'publish date', fatal=False)) | |
34646967 | 61 | comment_count = int(self._html_search_regex( |
fe556f1b | 62 | r'<meta name="num_comments" content="(\d+) Comments?"', |
34646967 | 63 | webpage, 'comment count', fatal=False)) |
a229909f NJ |
64 | |
65 | return { | |
66 | 'id': video_id, | |
67 | 'title': title, | |
68 | 'url': video_url, | |
a229909f NJ |
69 | 'thumbnail': thumbnail, |
70 | 'description': description, | |
71 | 'upload_date': publish_date, | |
fe556f1b | 72 | 'comment_count': comment_count, |
a229909f | 73 | } |