-# coding: utf-8
-from __future__ import unicode_literals
-
-import re
-
from .common import InfoExtractor
from ..utils import (
determine_ext,
get_elements_text_and_html_by_attribute,
- merge_dicts,
- unescapeHTML,
+ scale_thumbnails_to_max_format_width,
)
continue
formats.extend(formats_)
self._merge_subtitles(subs_, target=subs)
- self._sort_formats(formats)
return formats, subs
- @staticmethod
- def _scale_thumbnails_to_max_width(formats, thumbnails, url_width_re):
- _keys = ('width', 'height')
- max_dimensions = max(
- [tuple(format.get(k) or 0 for k in _keys) for format in formats],
- default=(0, 0))
- if not max_dimensions[0]:
- return thumbnails
- return [
- merge_dicts(
- {'url': re.sub(url_width_re, str(max_dimensions[0]), thumbnail['url'])},
- dict(zip(_keys, max_dimensions)), thumbnail)
- for thumbnail in thumbnails
- ]
-
def _real_extract(self, url):
netloc, video_id, display_id = self._match_valid_url(url).group('netloc', 'id', 'slug')
if netloc.find('tvopen.gr') == -1:
info['formats'], info['subtitles'] = self._extract_formats_and_subs(
self._download_json(self._API_ENDPOINT, video_id, query={'cid': video_id}),
video_id)
- info['thumbnails'] = self._scale_thumbnails_to_max_width(
+ info['thumbnails'] = scale_thumbnails_to_max_format_width(
info['formats'], info['thumbnails'], r'(?<=/imgHandler/)\d+')
description, _html = next(get_elements_text_and_html_by_attribute('class', 'description', webpage))
if description and _html.startswith('<span '):
IE_NAME = 'tvopengr:embed'
IE_DESC = 'tvopen.gr embedded videos'
_VALID_URL = r'(?:https?:)?//(?:www\.|cdn\.|)(?:tvopen|ethnos).gr/embed/(?P<id>\d+)'
- _EMBED_RE = re.compile(rf'''<iframe[^>]+?src=(?P<_q1>["'])(?P<url>{_VALID_URL})(?P=_q1)''')
+ _EMBED_REGEX = [rf'''<iframe[^>]+?src=(?P<_q1>["'])(?P<url>{_VALID_URL})(?P=_q1)''']
_TESTS = [{
'url': 'https://cdn.ethnos.gr/embed/100963',
},
}]
- @classmethod
- def _extract_urls(cls, webpage):
- for mobj in cls._EMBED_RE.finditer(webpage):
- yield unescapeHTML(mobj.group('url'))
-
def _real_extract(self, url):
video_id = self._match_id(url)
return self._return_canonical_url(url, video_id)