historicfilms.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from .common import InfoExtractor
  2. from ..utils import parse_duration
  3. class HistoricFilmsIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?historicfilms\.com/(?:tapes/|play)(?P<id>\d+)'
  5. _TEST = {
  6. 'url': 'http://www.historicfilms.com/tapes/4728',
  7. 'md5': 'd4a437aec45d8d796a38a215db064e9a',
  8. 'info_dict': {
  9. 'id': '4728',
  10. 'ext': 'mov',
  11. 'title': 'Historic Films: GP-7',
  12. 'description': 'md5:1a86a0f3ac54024e419aba97210d959a',
  13. 'thumbnail': r're:^https?://.*\.jpg$',
  14. 'duration': 2096,
  15. },
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. tape_id = self._search_regex(
  21. [r'class="tapeId"[^>]*>([^<]+)<', r'tapeId\s*:\s*"([^"]+)"'],
  22. 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 = f'http://www.historicfilms.com/video/{tape_id}_{video_id}_web.mov'
  30. return {
  31. 'id': video_id,
  32. 'url': video_url,
  33. 'title': title,
  34. 'description': description,
  35. 'thumbnail': thumbnail,
  36. 'duration': duration,
  37. }