helsinki.py 1.2 KB

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