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