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.

89 lines
2.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .subtitles import SubtitlesInfoExtractor
  5. from ..utils import (
  6. xpath_text,
  7. int_or_none,
  8. )
  9. class WallaIE(SubtitlesInfoExtractor):
  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)] = xpath_text(subtitle, './src')
  46. if self._downloader.params.get('listsubtitles', False):
  47. self._list_available_subtitles(video_id, subtitles)
  48. return
  49. subtitles = self.extract_subtitles(video_id, subtitles)
  50. formats = []
  51. for quality in item.findall('./qualities/quality'):
  52. format_id = xpath_text(quality, './title')
  53. fmt = {
  54. 'url': 'rtmp://wafla.walla.co.il/vod',
  55. 'play_path': xpath_text(quality, './src'),
  56. 'player_url': 'http://isc.walla.co.il/w9/swf/video_swf/vod/WallaMediaPlayerAvod.swf',
  57. 'page_url': url,
  58. 'ext': 'flv',
  59. 'format_id': xpath_text(quality, './title'),
  60. }
  61. m = re.search(r'^(?P<height>\d+)[Pp]', format_id)
  62. if m:
  63. fmt['height'] = int(m.group('height'))
  64. formats.append(fmt)
  65. self._sort_formats(formats)
  66. return {
  67. 'id': video_id,
  68. 'display_id': display_id,
  69. 'title': title,
  70. 'description': description,
  71. 'thumbnail': thumbnail,
  72. 'duration': duration,
  73. 'formats': formats,
  74. 'subtitles': subtitles,
  75. }