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