]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/howcast.py
debian/control: Make determination of python versions automatic.
[youtubedl] / youtube_dl / extractor / howcast.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class HowcastIE(InfoExtractor):
7 _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
8
9 def _real_extract(self, url):
10 mobj = re.match(self._VALID_URL, url)
11
12 video_id = mobj.group('id')
13 webpage_url = 'http://www.howcast.com/videos/' + video_id
14 webpage = self._download_webpage(webpage_url, video_id)
15
16 self.report_extraction(video_id)
17
18 video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
19 webpage, u'video URL')
20
21 video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
22 webpage, u'title')
23
24 video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
25 webpage, u'description', fatal=False)
26
27 thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
28 webpage, u'thumbnail', fatal=False)
29
30 return [{
31 'id': video_id,
32 'url': video_url,
33 'ext': 'mp4',
34 'title': video_title,
35 'description': video_description,
36 'thumbnail': thumbnail,
37 }]