]>
Commit | Line | Data |
---|---|---|
704df56d PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
1cc79574 | 7 | from ..utils import ( |
704df56d | 8 | parse_iso8601, |
5c2266df | 9 | sanitized_Request, |
704df56d PH |
10 | ) |
11 | ||
12 | ||
13 | class SportDeutschlandIE(InfoExtractor): | |
14 | _VALID_URL = r'https?://sportdeutschland\.tv/(?P<sport>[^/?#]+)/(?P<id>[^?#/]+)(?:$|[?#])' | |
3524cc25 | 15 | _TESTS = [{ |
704df56d PH |
16 | 'url': 'http://sportdeutschland.tv/badminton/live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen', |
17 | 'info_dict': { | |
18 | 'id': 'live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen', | |
19 | 'ext': 'mp4', | |
8ff14175 | 20 | 'title': 're:Li-Ning Badminton Weltmeisterschaft 2014 Kopenhagen', |
704df56d PH |
21 | 'categories': ['Badminton'], |
22 | 'view_count': int, | |
ec85ded8 YCH |
23 | 'thumbnail': r're:^https?://.*\.jpg$', |
24 | 'description': r're:Die Badminton-WM 2014 aus Kopenhagen bei Sportdeutschland\.TV', | |
3524cc25 PH |
25 | 'timestamp': int, |
26 | 'upload_date': 're:^201408[23][0-9]$', | |
704df56d PH |
27 | }, |
28 | 'params': { | |
29 | 'skip_download': 'Live stream', | |
30 | }, | |
3524cc25 PH |
31 | }, { |
32 | 'url': 'http://sportdeutschland.tv/li-ning-badminton-wm-2014/lee-li-ning-badminton-weltmeisterschaft-2014-kopenhagen-herren-einzel-wei-vs', | |
33 | 'info_dict': { | |
34 | 'id': 'lee-li-ning-badminton-weltmeisterschaft-2014-kopenhagen-herren-einzel-wei-vs', | |
35 | 'ext': 'mp4', | |
36 | 'upload_date': '20140825', | |
37 | 'description': 'md5:60a20536b57cee7d9a4ec005e8687504', | |
38 | 'timestamp': 1408976060, | |
c00c7c0a | 39 | 'duration': 2732, |
3524cc25 | 40 | 'title': 'Li-Ning Badminton Weltmeisterschaft 2014 Kopenhagen: Herren Einzel, Wei Lee vs. Keun Lee', |
ec85ded8 | 41 | 'thumbnail': r're:^https?://.*\.jpg$', |
3524cc25 PH |
42 | 'view_count': int, |
43 | 'categories': ['Li-Ning Badminton WM 2014'], | |
c00c7c0a | 44 | |
3524cc25 PH |
45 | } |
46 | }] | |
704df56d PH |
47 | |
48 | def _real_extract(self, url): | |
49 | mobj = re.match(self._VALID_URL, url) | |
50 | video_id = mobj.group('id') | |
51 | sport_id = mobj.group('sport') | |
52 | ||
c00c7c0a | 53 | api_url = 'http://proxy.vidibusdynamic.net/sportdeutschland.tv/api/permalinks/%s/%s?access_token=true' % ( |
704df56d | 54 | sport_id, video_id) |
5c2266df | 55 | req = sanitized_Request(api_url, headers={ |
704df56d PH |
56 | 'Accept': 'application/vnd.vidibus.v2.html+json', |
57 | 'Referer': url, | |
58 | }) | |
59 | data = self._download_json(req, video_id) | |
60 | ||
704df56d | 61 | asset = data['asset'] |
c00c7c0a | 62 | categories = [data['section']['title']] |
704df56d | 63 | |
3524cc25 | 64 | formats = [] |
c00c7c0a | 65 | smil_url = asset['video'] |
3524cc25 PH |
66 | if '.smil' in smil_url: |
67 | m3u8_url = smil_url.replace('.smil', '.m3u8') | |
68 | formats.extend( | |
69 | self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')) | |
70 | ||
71 | smil_doc = self._download_xml( | |
72 | smil_url, video_id, note='Downloading SMIL metadata') | |
9f610f3a PH |
73 | base_url_el = smil_doc.find('./head/meta') |
74 | if base_url_el: | |
75 | base_url = base_url_el.attrib['base'] | |
3524cc25 PH |
76 | formats.extend([{ |
77 | 'format_id': 'rmtp', | |
9f610f3a | 78 | 'url': base_url if base_url_el else n.attrib['src'], |
3524cc25 PH |
79 | 'play_path': n.attrib['src'], |
80 | 'ext': 'flv', | |
81 | 'preference': -100, | |
82 | 'format_note': 'Seems to fail at example stream', | |
83 | } for n in smil_doc.findall('./body/video')]) | |
84 | else: | |
85 | formats.append({'url': smil_url}) | |
704df56d | 86 | |
704df56d PH |
87 | self._sort_formats(formats) |
88 | ||
89 | return { | |
90 | 'id': video_id, | |
91 | 'formats': formats, | |
92 | 'title': asset['title'], | |
93 | 'thumbnail': asset.get('image'), | |
94 | 'description': asset.get('teaser'), | |
c00c7c0a | 95 | 'duration': asset.get('duration'), |
704df56d PH |
96 | 'categories': categories, |
97 | 'view_count': asset.get('views'), | |
3524cc25 | 98 | 'rtmp_live': asset.get('live'), |
704df56d PH |
99 | 'timestamp': parse_iso8601(asset.get('date')), |
100 | } |