]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/ehow.py
[ign] Fix extraction of video in articles
[youtube-dl.git] / youtube_dl / extractor / ehow.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from ..utils import (
6     compat_urllib_parse,
7 )
8 from .common import InfoExtractor
9
10
11 class EHowIE(InfoExtractor):
12     IE_NAME = 'eHow'
13     _VALID_URL = r'https?://(?:www\.)?ehow\.com/[^/_?]*_(?P<id>[0-9]+)'
14     _TEST = {
15         'url': 'http://www.ehow.com/video_12245069_hardwood-flooring-basics.html',
16         'md5': '9809b4e3f115ae2088440bcb4efbf371',
17         'info_dict': {
18             'id': '12245069',
19             'ext': 'flv',
20             'title': 'Hardwood Flooring Basics',
21             'description': 'Hardwood flooring may be time consuming, but its ultimately a pretty straightforward concept. Learn about hardwood flooring basics with help from a hardware flooring business owner in this free video...',
22             'uploader': 'Erick Nathan',
23         }
24     }
25
26     def _real_extract(self, url):
27         mobj = re.match(self._VALID_URL, url)
28         video_id = mobj.group('id')
29         webpage = self._download_webpage(url, video_id)
30         video_url = self._search_regex(r'(?:file|source)=(http[^\'"&]*)',
31             webpage, 'video URL')
32         final_url = compat_urllib_parse.unquote(video_url)
33         uploader = self._html_search_meta('uploader', webpage)
34         title = self._og_search_title(webpage).replace(' | eHow', '')
35
36         return {
37             'id': video_id,
38             'url': final_url,
39             'title': title,
40             'thumbnail': self._og_search_thumbnail(webpage),
41             'description': self._og_search_description(webpage),
42             'uploader': uploader,
43         }