2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
22 class OnetBaseIE(InfoExtractor
):
23 def _search_mvp_id(self
, webpage
):
24 return self
._search
_regex
(
25 r
'id=(["\'])mvp
:(?P
<id>.+?
)\
1', webpage, 'mvp
id', group='id')
27 def _extract_from_id(self, video_id, webpage=None):
28 response = self._download_json(
29 'http
://qi
.ckm
.onetapi
.pl
/', video_id,
32 'body
[jsonrpc
]': '2.0',
33 'body
[method
]': 'get_asset_detail
',
34 'body
[params
][ID_Publikacji
]': video_id,
35 'body
[params
][Service
]': 'www
.onet
.pl
',
36 'content
-type': 'application
/jsonp
',
37 'x
-onet
-app
': 'player
.front
.onetapi
.pl
',
40 error = response.get('error
')
43 '%s said
: %s' % (self.IE_NAME, error['message
']), expected=True)
45 video = response['result
'].get('0')
48 for _, formats_dict in video['formats
'].items():
49 if not isinstance(formats_dict, dict):
51 for format_id, format_list in formats_dict.items():
52 if not isinstance(format_list, list):
55 video_url = f.get('url
')
58 ext = determine_ext(video_url)
59 if format_id == 'ism
':
60 formats.extend(self._extract_ism_formats(
61 video_url, video_id, 'mss
', fatal=False))
63 formats.extend(self._extract_mpd_formats(
64 video_url, video_id, mpd_id='dash
', fatal=False))
68 'format_id
': format_id,
69 'height
': int_or_none(f.get('vertical_resolution
')),
70 'width
': int_or_none(f.get('horizontal_resolution
')),
71 'abr
': float_or_none(f.get('audio_bitrate
')),
72 'vbr
': float_or_none(f.get('video_bitrate
')),
74 self._sort_formats(formats)
76 meta = video.get('meta
', {})
78 title = (self._og_search_title(
79 webpage, default=None) if webpage else None) or meta['title
']
80 description = (self._og_search_description(
81 webpage, default=None) if webpage else None) or meta.get('description
')
82 duration = meta.get('length
') or meta.get('lenght
')
83 timestamp = parse_iso8601(meta.get('addDate
'), ' ')
88 'description
': description,
90 'timestamp
': timestamp,
95 class OnetMVPIE(OnetBaseIE):
96 _VALID_URL = r'onetmvp
:(?P
<id>\d
+\
.\d
+)'
99 'url
': 'onetmvp
:381027.1509591944',
100 'only_matching
': True,
103 def _real_extract(self, url):
104 return self._extract_from_id(self._match_id(url))
107 class OnetIE(OnetBaseIE):
108 _VALID_URL = r'https?
://(?
:www\
.)?onet\
.tv
/[a
-z
]/[a
-z
]+/(?P
<display_id
>[0-9a
-z
-]+)/(?P
<id>[0-9a
-z
]+)'
112 'url
': 'http
://onet
.tv
/k
/openerfestival
/open-er
-festival
-2016-najdziwniejsze
-wymagania
-gwiazd
/qbpyqc
',
113 'md5
': 'e3ffbf47590032ac3f27249204173d50
',
116 'display_id
': 'open-er
-festival
-2016-najdziwniejsze
-wymagania
-gwiazd
',
118 'title
': 'Open
\'er Festival
2016: najdziwniejsze wymagania gwiazd
',
119 '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
...',
120 'upload_date
': '20160705',
121 'timestamp
': 1467721580,
125 def _real_extract(self, url):
126 mobj = re.match(self._VALID_URL, url)
127 display_id, video_id = mobj.group('display_id
', 'id')
129 webpage = self._download_webpage(url, display_id)
131 mvp_id = self._search_mvp_id(webpage)
133 info_dict = self._extract_from_id(mvp_id, webpage)
136 'display_id
': display_id,
142 class OnetChannelIE(OnetBaseIE):
143 _VALID_URL = r'https?
://(?
:www\
.)?onet\
.tv
/[a
-z
]/(?P
<id>[a
-z
]+)(?
:[?
#]|$)'
144 IE_NAME
= 'onet.tv:channel'
147 'url': 'http://onet.tv/k/openerfestival',
149 'id': 'openerfestival',
150 'title': 'Open\'er Festival Live',
151 'description': 'Dziękujemy, że oglądaliście transmisje. Zobaczcie nasze relacje i wywiady z artystami.',
153 'playlist_mincount': 46,
156 def _real_extract(self
, url
):
157 channel_id
= self
._match
_id
(url
)
159 webpage
= self
._download
_webpage
(url
, channel_id
)
161 current_clip_info
= self
._parse
_json
(self
._search
_regex
(
162 r
'var\s+currentClip\s*=\s*({[^}]+})', webpage
, 'video info'), channel_id
,
163 transform_source
=lambda s
: js_to_json(re
.sub(r
'\'\s
*\
+\s
*\'', '', s)))
164 video_id = remove_start(current_clip_info['ckmId
'], 'mvp
:')
165 video_name = url_basename(current_clip_info['url
'])
167 if self._downloader.params.get('noplaylist
'):
169 'Downloading just video
%s because of
--no
-playlist
' % video_name)
170 return self._extract_from_id(video_id, webpage)
173 'Downloading channel
%s - add
--no
-playlist to just download video
%s' % (
174 channel_id, video_name))
175 matches = re.findall(
176 r'<a
[^
>]+href
=[\'"](https?://(?:www\.)?onet\.tv/[a-z]/[a-z]+/[0-9a-z-]+/[0-9a-z]+)',
179 self.url_result(video_link, OnetIE.ie_key())
180 for video_link in matches]
182 channel_title = strip_or_none(get_element_by_class('o_channelName', webpage))
183 channel_description = strip_or_none(get_element_by_class('o_channelDesc', webpage))
184 return self.playlist_result(entries, channel_id, channel_title, channel_description)
187 class OnetPlIE(InfoExtractor):
188 _VALID_URL = r'https?://(?:[^/]+\.)?(?:onet|businessinsider\.com|plejada)\.pl/(?:[^/]+/)+(?P<id>[0-9a-z]+)'
192 'url': 'http://eurosport.onet.pl/zimowe/skoki-narciarskie/ziobro-wygral-kwalifikacje-w-pjongczangu/9ckrly',
193 'md5': 'b94021eb56214c3969380388b6e73cb0',
195 'id': '1561707.1685479',
197 'title': 'Ziobro wygrał kwalifikacje w Pjongczangu',
198 'description': 'md5:61fb0740084d2d702ea96512a03585b4',
199 'upload_date': '20170214',
200 'timestamp': 1487078046,
203 # embedded via pulsembed
204 'url': 'http://film.onet.pl/pensjonat-nad-rozlewiskiem-relacja-z-planu-serialu/y428n0',
206 'id': '501235.965429946',
208 'title': '"Pensjonat nad rozlewiskiem
": relacja z planu serialu',
209 'upload_date': '20170622',
210 'timestamp': 1498159955,
213 'skip_download': True,
216 'url': 'http://film.onet.pl/zwiastuny/ghost-in-the-shell-drugi-zwiastun-pl/5q6yl3',
217 'only_matching': True,
219 'url': 'http://moto.onet.pl/jak-wybierane-sa-miejsca-na-fotoradary/6rs04e',
220 'only_matching': True,
222 'url': 'http://businessinsider.com.pl/wideo/scenariusz-na-koniec-swiata-wedlug-nasa/dwnqptk',
223 'only_matching': True,
225 'url': 'http://plejada.pl/weronika-rosati-o-swoim-domniemanym-slubie/n2bq89',
226 'only_matching': True,
229 def _search_mvp_id(self, webpage, default=NO_DEFAULT):
230 return self._search_regex(
231 r'data-(?:params-)?mvp=["\'](\d
+\
.\d
+)', webpage, 'mvp
id',
234 def _real_extract(self, url):
235 video_id = self._match_id(url)
237 webpage = self._download_webpage(url, video_id)
239 mvp_id = self._search_mvp_id(webpage, default=None)
242 pulsembed_url = self._search_regex(
243 r'data
-src
=(["\'])(?P<url>(?:https?:)?//pulsembed\.eu/.+?)\1',
244 webpage, 'pulsembed url', group='url')
245 webpage = self._download_webpage(
246 pulsembed_url, video_id, 'Downloading pulsembed webpage')
247 mvp_id = self._search_mvp_id(webpage)
249 return self.url_result(
250 'onetmvp:%s' % mvp_id, OnetMVPIE.ie_key(), video_id=mvp_id)