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.

43 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import js_to_json
  5. class HelsinkiIE(InfoExtractor):
  6. IE_DESC = 'helsinki.fi'
  7. _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)'
  8. _TEST = {
  9. 'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258',
  10. 'info_dict': {
  11. 'id': '20258',
  12. 'ext': 'mp4',
  13. 'title': 'Tietotekniikkafoorumi-iltapäivä',
  14. 'description': 'md5:f5c904224d43c133225130fe156a5ee0',
  15. },
  16. 'params': {
  17. 'skip_download': True, # RTMP
  18. }
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. params = self._parse_json(self._html_search_regex(
  24. r'(?s)jwplayer\("player"\).setup\((\{.*?\})\);',
  25. webpage, 'player code'), video_id, transform_source=js_to_json)
  26. formats = [{
  27. 'url': s['file'],
  28. 'ext': 'mp4',
  29. } for s in params['sources']]
  30. self._sort_formats(formats)
  31. return {
  32. 'id': video_id,
  33. 'title': self._og_search_title(webpage).replace('Video: ', ''),
  34. 'description': self._og_search_description(webpage),
  35. 'formats': formats,
  36. }