You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class HowcastIE(InfoExtractor):
  4. _VALID_URL = r'(?:https?://)?(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  5. def _real_extract(self, url):
  6. mobj = re.match(self._VALID_URL, url)
  7. video_id = mobj.group('id')
  8. webpage_url = 'http://www.howcast.com/videos/' + video_id
  9. webpage = self._download_webpage(webpage_url, video_id)
  10. self.report_extraction(video_id)
  11. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  12. webpage, u'video URL')
  13. video_title = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') property=\'og:title\'',
  14. webpage, u'title')
  15. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  16. webpage, u'description', fatal=False)
  17. thumbnail = self._html_search_regex(r'<meta content=\'(.+?)\' property=\'og:image\'',
  18. webpage, u'thumbnail', fatal=False)
  19. return [{
  20. 'id': video_id,
  21. 'url': video_url,
  22. 'ext': 'mp4',
  23. 'title': video_title,
  24. 'description': video_description,
  25. 'thumbnail': thumbnail,
  26. }]