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.

58 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. unescapeHTML,
  5. parse_duration,
  6. )
  7. class SSAIE(InfoExtractor):
  8. _VALID_URL = r'http://ssa\.nls\.uk/film/(?P<id>\d+)'
  9. _TEST = {
  10. 'url': 'http://ssa.nls.uk/film/3561',
  11. 'info_dict': {
  12. 'id': '3561',
  13. 'ext': 'flv',
  14. 'title': 'SHETLAND WOOL',
  15. 'description': 'md5:c5afca6871ad59b4271e7704fe50ab04',
  16. 'duration': 900,
  17. 'thumbnail': 're:^https?://.*\.jpg$',
  18. },
  19. 'params': {
  20. # rtmp download
  21. 'skip_download': True,
  22. },
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. streamer = self._search_regex(
  28. r"'streamer'\s*,\S*'(rtmp[^']+)'", webpage, 'streamer')
  29. play_path = self._search_regex(
  30. r"'file'\s*,\s*'([^']+)'", webpage, 'file').rpartition('.')[0]
  31. def search_field(field_name, fatal=False):
  32. return self._search_regex(
  33. r'<span\s+class="field_title">%s:</span>\s*<span\s+class="field_content">([^<]+)</span>' % field_name,
  34. webpage, 'title', fatal=fatal)
  35. title = unescapeHTML(search_field('Title', fatal=True)).strip('()[]')
  36. description = unescapeHTML(search_field('Description'))
  37. duration = parse_duration(search_field('Running time'))
  38. thumbnail = self._search_regex(
  39. r"'image'\s*,\s*'([^']+)'", webpage, 'thumbnails', fatal=False)
  40. return {
  41. 'id': video_id,
  42. 'url': streamer,
  43. 'play_path': play_path,
  44. 'ext': 'flv',
  45. 'title': title,
  46. 'description': description,
  47. 'duration': duration,
  48. 'thumbnail': thumbnail,
  49. }