[ant1newsgr] Add extractor (#1982)

Authored by: zmousm
This commit is contained in:
Zenon Mousmoulas
2022-03-04 23:52:48 +02:00
committed by GitHub
parent 50e93e03a7
commit 27231526ae
6 changed files with 181 additions and 19 deletions

View File

@@ -7,7 +7,7 @@ from .common import InfoExtractor
from ..utils import (
determine_ext,
get_elements_text_and_html_by_attribute,
merge_dicts,
scale_thumbnails_to_max_format_width,
unescapeHTML,
)
@@ -78,21 +78,6 @@ class TVOpenGrWatchIE(TVOpenGrBaseIE):
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:
@@ -102,7 +87,7 @@ class TVOpenGrWatchIE(TVOpenGrBaseIE):
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 '):