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.

46 lines
1.5 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import parse_duration
  4. class HistoricFilmsIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?historicfilms\.com/(?:tapes/|play)(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://www.historicfilms.com/tapes/4728',
  8. 'md5': 'd4a437aec45d8d796a38a215db064e9a',
  9. 'info_dict': {
  10. 'id': '4728',
  11. 'ext': 'mov',
  12. 'title': 'Historic Films: GP-7',
  13. 'description': 'md5:1a86a0f3ac54024e419aba97210d959a',
  14. 'thumbnail': 're:^https?://.*\.jpg$',
  15. 'duration': 2096,
  16. },
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. tape_id = self._search_regex(
  22. r'class="tapeId">([^<]+)<', webpage, 'tape id')
  23. title = self._og_search_title(webpage)
  24. description = self._og_search_description(webpage)
  25. thumbnail = self._html_search_meta(
  26. 'thumbnailUrl', webpage, 'thumbnails') or self._og_search_thumbnail(webpage)
  27. duration = parse_duration(self._html_search_meta(
  28. 'duration', webpage, 'duration'))
  29. video_url = 'http://www.historicfilms.com/video/%s_%s_web.mov' % (tape_id, video_id)
  30. return {
  31. 'id': video_id,
  32. 'url': video_url,
  33. 'title': title,
  34. 'description': description,
  35. 'thumbnail': thumbnail,
  36. 'duration': duration,
  37. }