From 35081ecf00d3c204f29daac04b9f608906cbc8dc Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Wed, 9 Feb 2022 21:15:01 +0200 Subject: [PATCH] Minor fixes --- youtube_dl/extractor/teleportal.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/teleportal.py b/youtube_dl/extractor/teleportal.py index b254ee3dc..6c976e7f6 100644 --- a/youtube_dl/extractor/teleportal.py +++ b/youtube_dl/extractor/teleportal.py @@ -22,15 +22,19 @@ class TeleportalIE(InfoExtractor): video_id = self._match_id(url) backend_url = 'https://tp-back.starlight.digital/ua/{}'.format(video_id) metadata = self._download_json(backend_url, video_id) - api_metadata = self._download_json('https://vcms-api2.starlight.digital/player-api/{}?referer=https://teleportal.ua/&lang=ua'.format(metadata["hash"]), video_id) + api_metadata = self._download_json('https://vcms-api2.starlight.digital/player-api/{}?referer=https://teleportal.ua/&lang=ua'.format(metadata['hash']), video_id) + + try: + thumbnail = api_metadata['video'][0]['poster'] + except (KeyError, IndexError): + thumbnail = None return { 'id': video_id, - 'title': metadata['title'], - 'description': metadata['description'], - 'real_id': metadata['id'], - 'hash': metadata['hash'], - 'url': api_metadata['video'][0]['mediaHls'], - 'thumbnail': api_metadata['video'][0]['poster'], + 'title': metadata.get('title'), + 'description': metadata.get('description'), + 'real_id': metadata.get('id'), + 'hash': metadata.get('hash'), + 'thumbnail': thumbnail, 'formats': self._extract_m3u8_formats(api_metadata['video'][0]['mediaHls'], video_id, 'mp4'), }