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

Code before:
        },
    }, {
        'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7',
        'info_dict': {
            'id': 'D5610AQFKo9M0zqY2_g',
            'display_id': 'the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7',
            'ext': 'mp4',
            'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?',
            'description': 'md5:95f9d4eeb6337882fb47eefe13d7a40c',
            'uploader': 'MathWorks',
            'thumbnail': 'https://media.licdn.com/dms/image/D5610AQFKo9M0zqY2_g/ads-video-thumbnail_720_1280/0/1704988806715?e=2147483647&v=beta&t=0vg-ksOY2KrL_QFlNacCv5Tmuk0tum9FJ_4dlJ56Gyw',
            'like_count': int,
            'subtitles': 'mincount:1'
        },
    }]

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

        title = self._og_search_title(webpage, default=None) or self._html_extract_title(webpage)
        description = self._og_search_description(webpage, default=None)
        json_ld_list = list(self._yield_json_ld(webpage, video_id))
        uploader = traverse_obj(
            json_ld_list, (lambda _, v: v['@type'] == 'SocialMediaPosting', 'author'), get_all=False).get('name')
        like_count = int_or_none(self._search_regex(r'<a href=[^>]+\sdata-num-reactions="(\d+)"', webpage, 'reactions', default=None))

        video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video'))
        print('video_attrs:', video_attrs)
        sources = self._parse_json(video_attrs['data-sources'], video_id)
        id = str(video_attrs.get('data-digitalmedia-asset-urn') or video_id).replace('urn:li:digitalmediaAsset:', '')
        formats = [{
            'url': source['src'],
            'ext': mimetype2ext(source.get('type')),
            'tbr': float_or_none(source.get('data-bitrate'), scale=1000),
        } for source in sources]
        subtitles = {'en': [{
            'url': video_attrs['data-captions-url'],
            'ext': 'vtt',
        }]} if url_or_none(video_attrs.get('data-captions-url')) else {}

        return {
            'id': id,
            'display_id': video_id,
            'formats': formats,
            'title': title,
            'like_count': like_count,
            'uploader': uploader,
            'thumbnail': self._og_search_thumbnail(webpage),
            'description': description,
            'subtitles': subtitles,

Review comment (refactor):
inline below, and I would simplify/relax the regex a bit
```suggestion
        like_count = int_or_none(self._search_regex(
            r'\bdata-num-reactions="(\d+)"', webpage, 'reactions', default=None))
```

Code after:
    }, {
        'url': 'https://www.linkedin.com/posts/the-mathworks_2_what-is-mathworks-cloud-center-activity-7151241570371948544-4Gu7',
        'info_dict': {
            'id': '7151241570371948544',
            'ext': 'mp4',
            'title': 'MathWorks on LinkedIn: What Is MathWorks Cloud Center?',
            'description': 'md5:95f9d4eeb6337882fb47eefe13d7a40c',
            'uploader': 'MathWorks',
            'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$',
            'like_count': int,
            'subtitles': 'mincount:1'
        },
    }]

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

        video_attrs = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video'))
        sources = self._parse_json(video_attrs['data-sources'], video_id)
        formats = [{
            'url': source['src'],
            'ext': mimetype2ext(source.get('type')),
            'tbr': float_or_none(source.get('data-bitrate'), scale=1000),
        } for source in sources]
        subtitles = {'en': [{
            'url': video_attrs['data-captions-url'],
            'ext': 'vtt',
        }]} if url_or_none(video_attrs.get('data-captions-url')) else {}

        return {
            'id': video_id,
            'formats': formats,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'like_count': int_or_none(self._search_regex(
                r'\bdata-num-reactions="(\d+)"', webpage, 'reactions', default=None)),
            'uploader': traverse_obj(
                self._yield_json_ld(webpage, video_id),
                (lambda _, v: v['@type'] == 'SocialMediaPosting', 'author', 'name', {str}), get_all=False),
            'thumbnail': self._og_search_thumbnail(webpage),
            'description': self._og_search_description(webpage, default=None),
            'subtitles': subtitles,
        }


class LinkedInLearningIE(LinkedInLearningBaseIE):
    IE_NAME = 'linkedin:learning'
    _VALID_URL = r'https?://(?:www\.)?linkedin\.com/learning/(?P<course_slug>[^/]+)/(?P<id>[^/?#]+)'
    _TEST = {
        'url': 'https://www.linkedin.com/learning/programming-foundations-fundamentals/welcome?autoplay=true',
        'md5': 'a1d74422ff0d5e66a792deb996693167',