howcast.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from .common import InfoExtractor
  2. from ..utils import parse_iso8601
  3. class HowcastIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
  5. _TEST = {
  6. 'url': 'http://www.howcast.com/videos/390161-How-to-Tie-a-Square-Knot-Properly',
  7. 'md5': '7d45932269a288149483144f01b99789',
  8. 'info_dict': {
  9. 'id': '390161',
  10. 'ext': 'mp4',
  11. 'title': 'How to Tie a Square Knot Properly',
  12. 'description': 'md5:dbe792e5f6f1489027027bf2eba188a3',
  13. 'timestamp': 1276081287,
  14. 'upload_date': '20100609',
  15. 'duration': 56.823,
  16. },
  17. 'params': {
  18. 'skip_download': True,
  19. },
  20. 'add_ie': ['Ooyala'],
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. embed_code = self._search_regex(
  26. r'<iframe[^>]+src="[^"]+\bembed_code=([^\b]+)\b',
  27. webpage, 'ooyala embed code')
  28. return {
  29. '_type': 'url_transparent',
  30. 'ie_key': 'Ooyala',
  31. 'url': 'ooyala:%s' % embed_code,
  32. 'id': video_id,
  33. 'timestamp': parse_iso8601(self._html_search_meta(
  34. 'article:published_time', webpage, 'timestamp')),
  35. }