From d24005da42baa9ba88abaacf4da8c7a079423350 Mon Sep 17 00:00:00 2001 From: YuenSzeHong Date: Thu, 16 Sep 2021 16:43:47 +0800 Subject: [PATCH 1/2] improve thumbnail resolution for tver --- youtube_dl/extractor/brightcove.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/youtube_dl/extractor/brightcove.py b/youtube_dl/extractor/brightcove.py index 6022076ac..8db3dc516 100644 --- a/youtube_dl/extractor/brightcove.py +++ b/youtube_dl/extractor/brightcove.py @@ -571,12 +571,28 @@ class BrightcoveNewIE(AdobePassIE): duration = float_or_none(json_data.get('duration'), 1000) if duration is not None and duration <= 0: is_live = True + common_res=["160x90","320x180","480x270","640x360","768x432","1024x576","1280x720","1366x768","1920x1080"] + thumbnails = [] + if '640x360' in json_data.get('poster'): + base_url = json_data.get('poster') + replace = '640x360' + else: + base_url = json_data.get('thumbnail') + replace = '160x90' + for res in common_res: + thumbnails.append({ + 'url': base_url.replace(replace, res), + 'width': int(res.split('x')[0]), + 'height': int(res.split('x')[1]), + 'preference': len(thumbnails) + }) return { 'id': video_id, 'title': self._live_title(title) if is_live else title, 'description': clean_html(json_data.get('description')), 'thumbnail': json_data.get('thumbnail') or json_data.get('poster'), + 'thumbnails': thumbnails, 'duration': duration, 'timestamp': parse_iso8601(json_data.get('published_at')), 'uploader_id': json_data.get('account_id'), From ab9555a5e396997f8f6173d6478010a83e778c4b Mon Sep 17 00:00:00 2001 From: YuenSzeHong Date: Thu, 16 Sep 2021 16:56:50 +0800 Subject: [PATCH 2/2] checked flake8 --- youtube_dl/extractor/brightcove.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/brightcove.py b/youtube_dl/extractor/brightcove.py index 8db3dc516..860e8d884 100644 --- a/youtube_dl/extractor/brightcove.py +++ b/youtube_dl/extractor/brightcove.py @@ -571,7 +571,7 @@ class BrightcoveNewIE(AdobePassIE): duration = float_or_none(json_data.get('duration'), 1000) if duration is not None and duration <= 0: is_live = True - common_res=["160x90","320x180","480x270","640x360","768x432","1024x576","1280x720","1366x768","1920x1080"] + common_res = ["160x90", "320x180", "480x270", "640x360", "768x432", "1024x576", "1280x720", "1366x768", "1920x1080"] thumbnails = [] if '640x360' in json_data.get('poster'): base_url = json_data.get('poster') @@ -582,7 +582,7 @@ class BrightcoveNewIE(AdobePassIE): for res in common_res: thumbnails.append({ 'url': base_url.replace(replace, res), - 'width': int(res.split('x')[0]), + 'width': int(res.split('x')[0]), 'height': int(res.split('x')[1]), 'preference': len(thumbnails) })