2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
21 class OnetBaseIE(InfoExtractor
):
22 def _search_mvp_id(self
, webpage
):
23 return self
._search
_regex
(
24 r
'id=(["\'])mvp
:(?P
<id>.+?
)\
1', webpage, 'mvp
id', group='id')
26 def _extract_from_id(self, video_id, webpage=None):
27 response = self._download_json(
28 'http
://qi
.ckm
.onetapi
.pl
/', video_id,
31 'body
[jsonrpc
]': '2.0',
32 'body
[method
]': 'get_asset_detail
',
33 'body
[params
][ID_Publikacji
]': video_id,
34 'body
[params
][Service
]': 'www
.onet
.pl
',
35 'content
-type': 'application
/jsonp
',
36 'x
-onet
-app
': 'player
.front
.onetapi
.pl
',
39 error = response.get('error
')
42 '%s said
: %s' % (self.IE_NAME, error['message
']), expected=True)
44 video = response['result
'].get('0')
47 for _, formats_dict in video['formats
'].items():
48 if not isinstance(formats_dict, dict):
50 for format_id, format_list in formats_dict.items():
51 if not isinstance(format_list, list):
54 video_url = f.get('url
')
57 ext = determine_ext(video_url)
58 if format_id == 'ism
':
59 formats.extend(self._extract_ism_formats(
60 video_url, video_id, 'mss
', fatal=False))
62 formats.extend(self._extract_mpd_formats(
63 video_url, video_id, mpd_id='dash
', fatal=False))
67 'format_id
': format_id,
68 'height
': int_or_none(f.get('vertical_resolution
')),
69 'width
': int_or_none(f.get('horizontal_resolution
')),
70 'abr
': float_or_none(f.get('audio_bitrate
')),
71 'vbr
': float_or_none(f.get('video_bitrate
')),
73 self._sort_formats(formats)
75 meta = video.get('meta
', {})
77 title = (self._og_search_title(
78 webpage, default=None) if webpage else None) or meta['title
']
79 description = (self._og_search_description(
80 webpage, default=None) if webpage else None) or meta.get('description
')
81 duration = meta.get('length
') or meta.get('lenght
')
82 timestamp = parse_iso8601(meta.get('addDate
'), ' ')
87 'description
': description,
89 'timestamp
': timestamp,
94 class OnetMVPIE(OnetBaseIE):
95 _VALID_URL = r'onetmvp
:(?P
<id>\d
+\
.\d
+)'
98 'url
': 'onetmvp
:381027.1509591944',
99 'only_matching
': True,
102 def _real_extract(self, url):
103 return self._extract_from_id(self._match_id(url))
106 class OnetIE(OnetBaseIE):
107 _VALID_URL = r'https?
://(?
:www\
.)?onet\
.tv
/[a
-z
]/[a
-z
]+/(?P
<display_id
>[0-9a
-z
-]+)/(?P
<id>[0-9a
-z
]+)'
111 'url
': 'http
://onet
.tv
/k
/openerfestival
/open-er
-festival
-2016-najdziwniejsze
-wymagania
-gwiazd
/qbpyqc
',
112 'md5
': 'e3ffbf47590032ac3f27249204173d50
',
115 'display_id
': 'open-er
-festival
-2016-najdziwniejsze
-wymagania
-gwiazd
',
117 'title
': 'Open
\'er Festival
2016: najdziwniejsze wymagania gwiazd
',
118 'description
': 'Trzy samochody
, których nigdy nie użyto
, prywatne spa
, hotel dekorowany czarnym suknem czy nielegalne używki
. Organizatorzy koncertów i festiwali muszą stawać przed nie lada wyzwaniem zapraszając gwia
...',
119 'upload_date
': '20160705',
120 'timestamp
': 1467721580,
124 def _real_extract(self, url):
125 mobj = re.match(self._VALID_URL, url)
126 display_id, video_id = mobj.group('display_id
', 'id')
128 webpage = self._download_webpage(url, display_id)
130 mvp_id = self._search_mvp_id(webpage)
132 info_dict = self._extract_from_id(mvp_id, webpage)
135 'display_id
': display_id,
141 class OnetChannelIE(OnetBaseIE):
142 _VALID_URL = r'https?
://(?
:www\
.)?onet\
.tv
/[a
-z
]/(?P
<id>[a
-z
]+)(?
:[?
#]|$)'
143 IE_NAME
= 'onet.tv:channel'
146 'url': 'http://onet.tv/k/openerfestival',
148 'id': 'openerfestival',
149 'title': 'Open\'er Festival Live',
150 'description': 'Dziękujemy, że oglądaliście transmisje. Zobaczcie nasze relacje i wywiady z artystami.',
152 'playlist_mincount': 46,
155 def _real_extract(self
, url
):
156 channel_id
= self
._match
_id
(url
)
158 webpage
= self
._download
_webpage
(url
, channel_id
)
160 current_clip_info
= self
._parse
_json
(self
._search
_regex
(
161 r
'var\s+currentClip\s*=\s*({[^}]+})', webpage
, 'video info'), channel_id
,
162 transform_source
=lambda s
: js_to_json(re
.sub(r
'\'\s
*\
+\s
*\'', '', s)))
163 video_id = remove_start(current_clip_info['ckmId
'], 'mvp
:')
164 video_name = url_basename(current_clip_info['url
'])
166 if self._downloader.params.get('noplaylist
'):
168 'Downloading just video
%s because of
--no
-playlist
' % video_name)
169 return self._extract_from_id(video_id, webpage)
172 'Downloading channel
%s - add
--no
-playlist to just download video
%s' % (
173 channel_id, video_name))
174 matches = re.findall(
175 r'<a
[^
>]+href
=[\'"](https?://(?:www\.)?onet\.tv/[a-z]/[a-z]+/[0-9a-z-]+/[0-9a-z]+)',
178 self.url_result(video_link, OnetIE.ie_key())
179 for video_link in matches]
181 channel_title = strip_or_none(get_element_by_class('o_channelName', webpage))
182 channel_description = strip_or_none(get_element_by_class('o_channelDesc', webpage))
183 return self.playlist_result(entries, channel_id, channel_title, channel_description)
186 class OnetPlIE(InfoExtractor):
187 _VALID_URL = r'https?://(?:[^/]+\.)?(?:onet|businessinsider\.com|plejada)\.pl/(?:[^/]+/)+(?P<id>[0-9a-z]+)'
191 'url': 'http://eurosport.onet.pl/zimowe/skoki-narciarskie/ziobro-wygral-kwalifikacje-w-pjongczangu/9ckrly',
192 'md5': 'b94021eb56214c3969380388b6e73cb0',
194 'id': '1561707.1685479',
196 'title': 'Ziobro wygrał kwalifikacje w Pjongczangu',
197 'description': 'md5:61fb0740084d2d702ea96512a03585b4',
198 'upload_date': '20170214',
199 'timestamp': 1487078046,
202 'url': 'http://film.onet.pl/zwiastuny/ghost-in-the-shell-drugi-zwiastun-pl/5q6yl3',
203 'only_matching': True,
205 'url': 'http://moto.onet.pl/jak-wybierane-sa-miejsca-na-fotoradary/6rs04e',
206 'only_matching': True,
208 'url': 'http://businessinsider.com.pl/wideo/scenariusz-na-koniec-swiata-wedlug-nasa/dwnqptk',
209 'only_matching': True,
211 'url': 'http://plejada.pl/weronika-rosati-o-swoim-domniemanym-slubie/n2bq89',
212 'only_matching': True,
215 def _real_extract(self, url):
216 video_id = self._match_id(url)
218 webpage = self._download_webpage(url, video_id)
220 mvp_id = self._search_regex(
221 r'data-params-mvp=["\'](\d
+\
.\d
+)', webpage, 'mvp
id')
223 return self.url_result(
224 'onetmvp
:%s' % mvp_id, OnetMVPIE.ie_key(), video_id=mvp_id)