howcast.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import parse_iso8601
  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': '7d45932269a288149483144f01b99789',
  9. 'info_dict': {
  10. 'id': '390161',
  11. 'ext': 'mp4',
  12. 'title': 'How to Tie a Square Knot Properly',
  13. 'description': 'md5:dbe792e5f6f1489027027bf2eba188a3',
  14. 'timestamp': 1276081287,
  15. 'upload_date': '20100609',
  16. 'duration': 56.823,
  17. },
  18. 'add_ie': ['Ooyala'],
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. embed_code = self._search_regex(
  24. r'<iframe[^>]+src="[^"]+\bembed_code=([^\b]+)\b',
  25. webpage, 'ooyala embed code')
  26. return {
  27. '_type': 'url_transparent',
  28. 'ie_key': 'Ooyala',
  29. 'url': 'ooyala:%s' % embed_code,
  30. 'id': video_id,
  31. 'timestamp': parse_iso8601(self._html_search_meta(
  32. 'article:published_time', webpage, 'timestamp')),
  33. }