logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

movingimage.py (1774B)


  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. unescapeHTML,
  5. parse_duration,
  6. )
  7. class MovingImageIE(InfoExtractor):
  8. _VALID_URL = r'https?://movingimage\.nls\.uk/film/(?P<id>\d+)'
  9. _TEST = {
  10. 'url': 'http://movingimage.nls.uk/film/3561',
  11. 'md5': '4caa05c2b38453e6f862197571a7be2f',
  12. 'info_dict': {
  13. 'id': '3561',
  14. 'ext': 'mp4',
  15. 'title': 'SHETLAND WOOL',
  16. 'description': 'md5:c5afca6871ad59b4271e7704fe50ab04',
  17. 'duration': 900,
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. webpage = self._download_webpage(url, video_id)
  24. formats = self._extract_m3u8_formats(
  25. self._html_search_regex(r'file\s*:\s*"([^"]+)"', webpage, 'm3u8 manifest URL'),
  26. video_id, ext='mp4', entry_protocol='m3u8_native')
  27. def search_field(field_name, fatal=False):
  28. return self._search_regex(
  29. r'<span\s+class="field_title">%s:</span>\s*<span\s+class="field_content">([^<]+)</span>' % field_name,
  30. webpage, 'title', fatal=fatal)
  31. title = unescapeHTML(search_field('Title', fatal=True)).strip('()[]')
  32. description = unescapeHTML(search_field('Description'))
  33. duration = parse_duration(search_field('Running time'))
  34. thumbnail = self._search_regex(
  35. r"image\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False)
  36. return {
  37. 'id': video_id,
  38. 'formats': formats,
  39. 'title': title,
  40. 'description': description,
  41. 'duration': duration,
  42. 'thumbnail': thumbnail,
  43. }