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.

41 lines
1.5 KiB

10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class HowcastIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://www.howcast.com/videos/390161-How-to-Tie-a-Square-Knot-Properly',
  8. 'md5': '8b743df908c42f60cf6496586c7f12c3',
  9. 'info_dict': {
  10. 'id': '390161',
  11. 'ext': 'mp4',
  12. 'description': 'The square knot, also known as the reef knot, is one of the oldest, most basic knots to tie, and can be used in many different ways. Here\'s the proper way to tie a square knot.',
  13. 'title': 'How to Tie a Square Knot Properly',
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage = self._download_webpage(url, video_id)
  20. self.report_extraction(video_id)
  21. video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
  22. webpage, 'video URL')
  23. video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
  24. webpage, 'description', fatal=False)
  25. return {
  26. 'id': video_id,
  27. 'url': video_url,
  28. 'title': self._og_search_title(webpage),
  29. 'description': video_description,
  30. 'thumbnail': self._og_search_thumbnail(webpage),
  31. }