2 from __future__ import unicode_literals
5 from datetime import datetime
7 from .common import InfoExtractor
8 from ..utils import determine_ext, ExtractorError
11 class JoveIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?jove\.com/video/(?P<id>[0-9]+)'
13 _CHAPTERS_URL = 'http://www.jove.com/video-chapters?videoid={video_id:}'
15 'url': 'http://www.jove.com/video/2744/electrode-positioning-montage-transcranial-direct-current',
16 'md5': '93723888d82dbd6ba8b3d7d0cd65dd2b',
20 'title': 'Electrode Positioning and Montage in Transcranial Direct Current Stimulation',
21 'description': 'Transcranial direct current stimulation (tDCS) is an established technique to modulate cortical excitability1,2. It has been ...',
22 'thumbnail': 're:^https?://.*\.png$',
23 'upload_date': '20110523',
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
31 webpage = self._download_webpage(url, video_id)
32 title = self._html_search_meta('citation_title', webpage, 'title')
33 thumbnail = self._og_search_thumbnail(webpage)
34 description = self._html_search_meta(
35 'description', webpage, 'description', fatal=False)
36 publish_date = self._html_search_meta(
37 'citation_publication_date', webpage, 'publish date', fatal=False)
39 publish_date = datetime.strptime(publish_date,
40 '%Y/%m/%d').strftime('%Y%m%d')
42 # Not the same as video_id.
43 chapters_id = self._html_search_regex(
44 r'/video-chapters\?videoid=([0-9]+)', webpage, 'chapters id')
45 chapters_xml = self._download_xml(
46 self._CHAPTERS_URL.format(video_id=chapters_id),
47 video_id, note='Downloading chapter XML',
48 errnote='Failed to download chapter XML'
50 video_url = chapters_xml.attrib.get('video')
52 raise ExtractorError('Failed to get the video URL')
54 ext = determine_ext(video_url)
61 'thumbnail': thumbnail,
62 'description': description,
63 'upload_date': publish_date,