+ page_id = self._match_id(url)
+ webpage = self._download_webpage(url, page_id)
+ video_id = self._search_regex([
+ r'<iframe[^>]+src="[^"]*?object_id=(\d+)',
+ r"object_id\s*:\s*'(\d+)'",
+ r'data-video-id="(\d+)"'], webpage, 'video id', default=page_id)
+ return {
+ '_type': 'url_transparent',
+ 'url': 'tvp:' + video_id,
+ 'description': self._og_search_description(
+ webpage, default=None) or self._html_search_meta(
+ 'description', webpage, default=None),
+ 'thumbnail': self._og_search_thumbnail(webpage, default=None),
+ 'ie_key': 'TVPEmbed',
+ }
+
+
+class TVPEmbedIE(InfoExtractor):
+ IE_NAME = 'tvp:embed'
+ IE_DESC = 'Telewizja Polska'
+ _VALID_URL = r'(?:tvp:|https?://[^/]+\.tvp\.(?:pl|info)/sess/tvplayer\.php\?.*?object_id=)(?P<id>\d+)'
+
+ _TESTS = [{
+ 'url': 'tvp:194536',
+ 'md5': 'a21eb0aa862f25414430f15fdfb9e76c',
+ 'info_dict': {
+ 'id': '194536',
+ 'ext': 'mp4',
+ 'title': 'Czas honoru, odc. 13 – Władek',
+ },
+ }, {
+ # not available
+ 'url': 'http://www.tvp.pl/sess/tvplayer.php?object_id=22670268',
+ 'md5': '8c9cd59d16edabf39331f93bf8a766c7',
+ 'info_dict': {
+ 'id': '22670268',
+ 'ext': 'mp4',
+ 'title': 'Panorama, 07.12.2015, 15:40',
+ },
+ 'skip': 'Transmisja została zakończona lub materiał niedostępny',
+ }, {
+ 'url': 'tvp:22670268',
+ 'only_matching': True,
+ }]
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+
+ webpage = self._download_webpage(
+ 'http://www.tvp.pl/sess/tvplayer.php?object_id=%s' % video_id, video_id)
+
+ error = self._html_search_regex(
+ r'(?s)<p[^>]+\bclass=["\']notAvailable__text["\'][^>]*>(.+?)</p>',
+ webpage, 'error', default=None) or clean_html(
+ get_element_by_attribute('class', 'msg error', webpage))
+ if error:
+ raise ExtractorError('%s said: %s' % (
+ self.IE_NAME, clean_html(error)), expected=True)
+
+ title = self._search_regex(
+ r'name\s*:\s*([\'"])Title\1\s*,\s*value\s*:\s*\1(?P<title>.+?)\1',
+ webpage, 'title', group='title')
+ series_title = self._search_regex(
+ r'name\s*:\s*([\'"])SeriesTitle\1\s*,\s*value\s*:\s*\1(?P<series>.+?)\1',
+ webpage, 'series', group='series', default=None)
+ if series_title:
+ title = '%s, %s' % (series_title, title)