ehow.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import re
  2. from ..utils import compat_urllib_parse
  3. from .common import InfoExtractor
  4. class EhowIE(InfoExtractor):
  5. _VALID_URL = r'(?:http://)?(?:www\.)?ehow\.com/([^/]+)'
  6. _TEST = {
  7. u'url': u'http://www.ehow.com/video_12245069_hardwood-flooring-basics.html',
  8. u'file': u'12245069.flv',
  9. u'md5': u'9809b4e3f115ae2088440bcb4efbf371',
  10. u'info_dict': {
  11. u"title": u"Hardwood Flooring Basics",
  12. u"description": u"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...",
  13. u"uploader": u"Erick Nathan"
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group(1).split("_")[1]
  19. webpage = self._download_webpage(url, video_id)
  20. video_url = self._search_regex(r'[^A-Za-z0-9]?(?:file|source)=(http[^\'"&]*)',
  21. webpage, u'video URL')
  22. final_url = compat_urllib_parse.unquote(video_url)
  23. thumbnail_url = self._search_regex(r'<meta property="og:image" content="(.+?)" />',
  24. webpage, u'thumbnail URL')
  25. uploader = self._search_regex(r'<meta name="uploader" content="(.+?)" />',
  26. webpage, u'uploader')
  27. title = self._search_regex(r'<meta property="og:title" content="(.+?)" />',
  28. webpage, u'Video title').replace(' | eHow','')
  29. description = self._search_regex(r'<meta property="og:description" content="(.+?)" />',
  30. webpage, u'video description')
  31. ext = final_url.split('.')[-1]
  32. return [{
  33. 'id': video_id,
  34. 'url': final_url,
  35. 'ext': ext,
  36. 'title': title,
  37. 'thumbnail': thumbnail_url,
  38. 'description': description,
  39. 'uploader': uploader,
  40. }]