walla.py 2.7 KB

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