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.

86 lines
2.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. xpath_text,
  7. int_or_none,
  8. )
  9. class WallaIE(InfoExtractor):
  10. _VALID_URL = r'http://vod\.walla\.co\.il/[^/]+/(?P<id>\d+)/(?P<display_id>.+)'
  11. _TEST = {
  12. 'url': 'http://vod.walla.co.il/movie/2642630/one-direction-all-for-one',
  13. 'info_dict': {
  14. 'id': '2642630',
  15. 'display_id': 'one-direction-all-for-one',
  16. 'ext': 'flv',
  17. 'title': 'וואן דיירקשן: ההיסטריה',
  18. 'description': 'md5:de9e2512a92442574cdb0913c49bc4d8',
  19. 'thumbnail': 're:^https?://.*\.jpg',
  20. 'duration': 3600,
  21. },
  22. 'params': {
  23. # rtmp download
  24. 'skip_download': True,
  25. }
  26. }
  27. _SUBTITLE_LANGS = {
  28. 'עברית': 'heb',
  29. }
  30. def _real_extract(self, url):
  31. mobj = re.match(self._VALID_URL, url)
  32. video_id = mobj.group('id')
  33. display_id = mobj.group('display_id')
  34. video = self._download_xml(
  35. 'http://video2.walla.co.il/?w=null/null/%s/@@/video/flv_pl' % video_id,
  36. display_id)
  37. item = video.find('./items/item')
  38. title = xpath_text(item, './title', 'title')
  39. description = xpath_text(item, './synopsis', 'description')
  40. thumbnail = xpath_text(item, './preview_pic', 'thumbnail')
  41. duration = int_or_none(xpath_text(item, './duration', 'duration'))
  42. subtitles = {}
  43. for subtitle in item.findall('./subtitles/subtitle'):
  44. lang = xpath_text(subtitle, './title')
  45. subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
  46. 'ext': 'srt',
  47. 'url': xpath_text(subtitle, './src'),
  48. }]
  49. formats = []
  50. for quality in item.findall('./qualities/quality'):
  51. format_id = xpath_text(quality, './title')
  52. fmt = {
  53. 'url': 'rtmp://wafla.walla.co.il/vod',
  54. 'play_path': xpath_text(quality, './src'),
  55. 'player_url': 'http://isc.walla.co.il/w9/swf/video_swf/vod/WallaMediaPlayerAvod.swf',
  56. 'page_url': url,
  57. 'ext': 'flv',
  58. 'format_id': xpath_text(quality, './title'),
  59. }
  60. m = re.search(r'^(?P<height>\d+)[Pp]', format_id)
  61. if m:
  62. fmt['height'] = int(m.group('height'))
  63. formats.append(fmt)
  64. self._sort_formats(formats)
  65. return {
  66. 'id': video_id,
  67. 'display_id': display_id,
  68. 'title': title,
  69. 'description': description,
  70. 'thumbnail': thumbnail,
  71. 'duration': duration,
  72. 'formats': formats,
  73. 'subtitles': subtitles,
  74. }