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

Code before:
        content_id = str_or_none(try_get(
            player_page, lambda x: x['tracking']['atiCustomVars']['contentId']))
        media_collection = player_page.get('mediaCollection') or {}
        if not media_collection and content_id:
            media_collection = self._download_json(
                'https://www.ardmediathek.de/play/media/' + content_id,
                content_id, fatal=False) or {}
        info = self._parse_media_info(
            media_collection, content_id or video_id,
            player_page.get('blockedByFsk'))
        age_limit = None
        description = player_page.get('synopsis')
        maturity_content_rating = player_page.get('maturityContentRating')
        if maturity_content_rating:
            age_limit = int_or_none(maturity_content_rating.lstrip('FSK'))
        if not age_limit and description:
            age_limit = int_or_none(self._search_regex(
                r'\(FSK\s*(\d+)\)\s*$', description, 'age limit', default=None))
        info.update({
            'age_limit': age_limit,
            'display_id': display_id,
            'title': title,
            'description': description,
            'timestamp': unified_timestamp(player_page.get('broadcastedOn')),
            'series': try_get(player_page, lambda x: x['show']['title']),
            'thumbnail': try_get(player_page, lambda x: x['image']['src'].replace('{width}', '1280')),
        })
        info.update(self._ARD_extract_episode_info(info['title']))
        if not info.get('thumbnail'):
            webpage = self._download_webpage(url, display_id, fatal=False) or ''
            info['thumbnail'] = (
                self._og_search_thumbnail(webpage, default=None)
                or self._html_search_meta('thumbnailUrl', webpage, default=None))
        return info


Review comment (suggestion):
The SEO tags were using 1280, so that seems to be some default number decided by ard. But also bigger numbers work, I am just not sure if they are actually higher quality or just scaled up. The maximum resolution I could get in my test is 4096, higher numbers fell back on 4096. It is a strange number for image width though.

E.g. https://api.ardmediathek.de/image-service/images/urn:ard:image:fbb21142783b0a49?w=4320&ch=ee69108ae344f678 will return an image with resolution 4096x2304 

Code after:
        title = player_page['title']
        content_id = str_or_none(try_get(
            player_page, lambda x: x['tracking']['atiCustomVars']['contentId']))
        media_collection = player_page.get('mediaCollection') or {}
        if not media_collection and content_id:
            media_collection = self._download_json(
                'https://www.ardmediathek.de/play/media/' + content_id,
                content_id, fatal=False) or {}
        info = self._parse_media_info(
            media_collection, content_id or video_id,
            player_page.get('blockedByFsk'))
        age_limit = None
        description = player_page.get('synopsis')
        maturity_content_rating = player_page.get('maturityContentRating')
        if maturity_content_rating:
            age_limit = int_or_none(maturity_content_rating.lstrip('FSK'))
        if not age_limit and description:
            age_limit = int_or_none(self._search_regex(
                r'\(FSK\s*(\d+)\)\s*$', description, 'age limit', default=None))
        info.update({
            'age_limit': age_limit,
            'display_id': display_id,
            'title': title,
            'description': description,
            'timestamp': unified_timestamp(player_page.get('broadcastedOn')),
            'series': try_get(player_page, lambda x: x['show']['title']),
            'thumbnail': (media_collection.get('_previewImage')
                          or try_get(player_page, lambda x: update_url(x['image']['src'], query=None, fragment=None))
                          or self.get_thumbnail_from_html(display_id, url)),
        })
        info.update(self._ARD_extract_episode_info(info['title']))
        return info

    def get_thumbnail_from_html(self, display_id, url):
        webpage = self._download_webpage(url, display_id, fatal=False) or ''
        return (
            self._og_search_thumbnail(webpage, default=None)
            or self._html_search_meta('thumbnailUrl', webpage, default=None))