]>
Commit | Line | Data |
---|---|---|
b6674528 | 1 | from .common import InfoExtractor |
0b75c2a8 | 2 | from ..utils import ExtractorError |
b6674528 | 3 | |
4 | ||
5 | class Sport5IE(InfoExtractor): | |
5886b38d | 6 | _VALID_URL = r'https?://(?:www|vod)?\.sport5\.co\.il/.*\b(?:Vi|docID)=(?P<id>\d+)' |
0b75c2a8 S |
7 | _TESTS = [ |
8 | { | |
b6674528 | 9 | 'url': 'http://vod.sport5.co.il/?Vc=147&Vi=176331&Page=1', |
10 | 'info_dict': { | |
11 | 'id': 's5-Y59xx1-GUh2', | |
12 | 'ext': 'mp4', | |
0b75c2a8 S |
13 | 'title': 'ולנסיה-קורדובה 0:3', |
14 | 'description': 'אלקאסר, גאייה ופגולי סידרו לקבוצה של נונו ניצחון על קורדובה ואת המקום הראשון בליגה', | |
15 | 'duration': 228, | |
16 | 'categories': list, | |
17 | }, | |
18 | 'skip': 'Blocked outside of Israel', | |
b6674528 | 19 | }, { |
20 | 'url': 'http://www.sport5.co.il/articles.aspx?FolderID=3075&docID=176372&lang=HE', | |
21 | 'info_dict': { | |
22 | 'id': 's5-SiXxx1-hKh2', | |
23 | 'ext': 'mp4', | |
0b75c2a8 S |
24 | 'title': 'GOALS_CELTIC_270914.mp4', |
25 | 'description': '', | |
26 | 'duration': 87, | |
27 | 'categories': list, | |
28 | }, | |
29 | 'skip': 'Blocked outside of Israel', | |
b6674528 | 30 | } |
31 | ] | |
32 | ||
33 | def _real_extract(self, url): | |
5ad28e7f | 34 | mobj = self._match_valid_url(url) |
0b75c2a8 | 35 | media_id = mobj.group('id') |
b6674528 | 36 | |
0b75c2a8 | 37 | webpage = self._download_webpage(url, media_id) |
b6674528 | 38 | |
ec85ded8 | 39 | video_id = self._html_search_regex(r'clipId=([\w-]+)', webpage, 'video id') |
b6674528 | 40 | |
0b75c2a8 S |
41 | metadata = self._download_xml( |
42 | 'http://sport5-metadata-rr-d.nsacdn.com/vod/vod/%s/HDS/metadata.xml' % video_id, | |
43 | video_id) | |
b6674528 | 44 | |
0b75c2a8 S |
45 | error = metadata.find('./Error') |
46 | if error is not None: | |
47 | raise ExtractorError( | |
48 | '%s returned error: %s - %s' % ( | |
49 | self.IE_NAME, | |
50 | error.find('./Name').text, | |
51 | error.find('./Description').text), | |
52 | expected=True) | |
b6674528 | 53 | |
0b75c2a8 S |
54 | title = metadata.find('./Title').text |
55 | description = metadata.find('./Description').text | |
56 | duration = int(metadata.find('./Duration').text) | |
b6674528 | 57 | |
0b75c2a8 S |
58 | posters_el = metadata.find('./PosterLinks') |
59 | thumbnails = [{ | |
60 | 'url': thumbnail.text, | |
61 | 'width': int(thumbnail.get('width')), | |
62 | 'height': int(thumbnail.get('height')), | |
63 | } for thumbnail in posters_el.findall('./PosterIMG')] if posters_el is not None else [] | |
64 | ||
65 | categories_el = metadata.find('./Categories') | |
66 | categories = [ | |
67 | cat.get('name') for cat in categories_el.findall('./Category') | |
68 | ] if categories_el is not None else [] | |
b6674528 | 69 | |
0b75c2a8 S |
70 | formats = [{ |
71 | 'url': fmt.text, | |
72 | 'ext': 'mp4', | |
73 | 'vbr': int(fmt.get('bitrate')), | |
74 | 'width': int(fmt.get('width')), | |
75 | 'height': int(fmt.get('height')), | |
76 | } for fmt in metadata.findall('./PlaybackLinks/FileURL')] | |
b6674528 | 77 | |
78 | return { | |
0b75c2a8 | 79 | 'id': video_id, |
b6674528 | 80 | 'title': title, |
0b75c2a8 S |
81 | 'description': description, |
82 | 'thumbnails': thumbnails, | |
b6674528 | 83 | 'duration': duration, |
0b75c2a8 | 84 | 'categories': categories, |
b6674528 | 85 | 'formats': formats, |
5f6a1245 | 86 | } |