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