helsinki.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class HelsinkiIE(InfoExtractor):
  6. _VALID_URL = r'https?://video\.helsinki\.fi/Arkisto/flash\.php\?id=(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'http://video.helsinki.fi/Arkisto/flash.php?id=20258',
  9. 'md5': 'cd829201b890905682eb194cbdea55d7',
  10. 'info_dict': {
  11. 'id': '20258',
  12. 'ext': 'mp4',
  13. 'title': 'Tietotekniikkafoorumi-iltapäivä',
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. vid = mobj.group('id')
  19. webpage = self._download_webpage(url, vid)
  20. formats = []
  21. mobj = re.search('file=((\w+):[^&]+)', webpage)
  22. if mobj: formats.append({
  23. 'ext': mobj.group(2),
  24. 'play_path': mobj.group(1),
  25. 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
  26. 'player_url': 'http://video.helsinki.fi/player.swf',
  27. 'format_note': 'sd'
  28. })
  29. mobj = re.search('hd\.file=((\w+):[^&]+)', webpage)
  30. if mobj: formats.append({
  31. 'ext': mobj.group(2),
  32. 'play_path': mobj.group(1),
  33. 'url': 'rtmp://flashvideo.it.helsinki.fi/vod/',
  34. 'player_url': 'http://video.helsinki.fi/player.swf',
  35. 'format_note': 'hd'
  36. })
  37. return {
  38. 'id': vid,
  39. 'title': self._og_search_title(webpage).replace('Video: ', ''),
  40. 'description': self._og_search_description(webpage),
  41. 'thumbnail': self._og_search_thumbnail(webpage),
  42. 'formats': formats
  43. }