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.

62 lines
1.9 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  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. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. webpage = self._download_webpage(url, video_id)
  24. formats = []
  25. mobj = re.search(r'file=((\w+):[^&]+)', webpage)
  26. if mobj:
  27. formats.append({
  28. 'ext': mobj.group(2),
  29. 'play_path': mobj.group(1),
  30. 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
  31. 'player_url': 'http://video.helsinki.fi/player.swf',
  32. 'format_note': 'sd',
  33. 'quality': 0,
  34. })
  35. mobj = re.search(r'hd\.file=((\w+):[^&]+)', webpage)
  36. if mobj:
  37. formats.append({
  38. 'ext': mobj.group(2),
  39. 'play_path': mobj.group(1),
  40. 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
  41. 'player_url': 'http://video.helsinki.fi/player.swf',
  42. 'format_note': 'hd',
  43. 'quality': 1,
  44. })
  45. self._sort_formats(formats)
  46. return {
  47. 'id': video_id,
  48. 'title': self._og_search_title(webpage).replace('Video: ', ''),
  49. 'description': self._og_search_description(webpage),
  50. 'thumbnail': self._og_search_thumbnail(webpage),
  51. 'formats': formats,
  52. }