Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/eltrecetv.py (Python)

Code before:
            }
        },
        {
            'url': 'https://www.eltrecetv.com.ar/argentina-tierra-de-amor-y-venganza/capitulos/temporada-2023/atav-2-capitulo-121-del-250923/',
            'only_matching': True,
        },
        {
            'url': 'https://www.eltrecetv.com.ar/ahora-caigo/capitulos/temporada-2023/programa-del-250923/',
            'only_matching': True,
        },
        {
            'url': 'https://www.eltrecetv.com.ar/pasaplatos/capitulos/temporada-2023/pasaplatos-el-restaurante-del-250923/',
            'only_matching': True,
        },
        {
            'url': 'https://www.eltrecetv.com.ar/el-galpon/capitulos/temporada-2023/programa-del-160923-invitado-raul-lavie/',
            'only_matching': True,
        }
    ]

    def _real_extract(self, url):
        slug = self._match_id(url)
        webpage = self._download_webpage(url, slug)

        json_all = self._search_json(r'Fusion.globalContent\s*=', webpage, 'content', slug)
        config = json_all.get('promo_items').get('basic').get('embed').get('config')

        title = config.get('title')
        thumbnail = config.get('thumbnail')
        url = config.get('m3u8')

        video_id = self._search_regex(r'/([A-Z0-9]+).(?:jpg|png)', thumbnail, 'video_id')

        formats = self._extract_m3u8_formats(url, video_id, ext='mp4', entry_protocol='http')

        for f in formats:
            # Edit url if points to a segment playlist to point to actual video
            f['url'] = f['url'].replace('/tracks-v1a1/index.m3u8', '')

        # hide 1080p format because it's not really available
        formats = [f for f in formats if f['height'] != 1080]

        return {
            'id': video_id,
            'title': title,
            'thumbnail': thumbnail,
            'formats': formats,
        }


Review comment (suggestion):
Avoid chaining `.get()`s
Use `traverse_obj()` for non-fatal traversal.
But here it should be fatal if these keys don't exist:
```suggestion
        config = self._search_json(
            r'Fusion\.globalContent\s*=', webpage, 'content', slug)['promo_items']['basic']['embed']['config']
```

Code after:
            'only_matching': True,
        }
    ]

    def _real_extract(self, url):
        slug = self._match_id(url)
        webpage = self._download_webpage(url, slug)
        config = self._search_json(
            r'Fusion.globalContent\s*=', webpage, 'content', slug)['promo_items']['basic']['embed']['config']
        video_url = config['m3u8']
        video_id = self._search_regex(r'/(\w+)\.m3u8', video_url, 'video id', default=slug)

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, video_id, 'mp4', m3u8_id='hls')
        formats.extend([{
            'url': f['url'][:-23],
            'format_id': f['format_id'].replace('hls', 'http'),
            'width': f.get('width'),
            'height': f.get('height'),
        } for f in formats if f['url'].endswith('/tracks-v1a1/index.m3u8') and f.get('height') != 1080])

        return {
            'id': video_id,
            'title': config.get('title'),
            'thumbnail': config.get('thumbnail'),
            'formats': formats,
            'subtitles': subtitles,
        }