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

Code before:
            'title': 'Mishal K. on LinkedIn: #sendinblueviews #toronto #digitalmarketing',
            'description': 'md5:be125430bab1c574f16aeb186a4d5b19',
            'creator': 'Mishal K.'
        },
    }]

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

        title = self._html_extract_title(webpage)
        description = clean_html(get_element_by_class('share-update-card__update-text', webpage))
        like_count = int_or_none(get_element_by_class('social-counts-reactions__social-counts-numRections', webpage))
        creator = strip_or_none(clean_html(get_element_by_class('comment__actor-name', webpage)))

        video_json = extract_attributes(self._search_regex(r'(<video[^>]+>)', webpage, 'video'))
        sources = self._parse_json(video_json['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 = {}
        sub_url = video_json.get('data-captions-url')
        if sub_url:
            subtitles.setdefault('en', []).append({'url': sub_url, 'ext': 'vtt'})

        return {
            'id': video_id,
            'formats': formats,
            'title': title,
            'like_count': like_count,
            'creator': creator,
            'thumbnail': self._og_search_thumbnail(webpage),
            'description': description,
            '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',
        'info_dict': {
            'id': '90426',
            'ext': 'mp4',
            'title': 'Welcome',
            'timestamp': 1430396150.82,
            'upload_date': '20150430',

Review comment (suggestion):
I'd do:
```suggestion
        subtitles = {'en': [{
            'url': video_attrs['data-captions-url'],
            'ext': 'vtt',
        }]} if url_or_none(video_attrs.get('data-captions-url')) else {}
```

Code after:
            'description': 'md5:2998a31f6f479376dd62831f53a80f71',
            'uploader': 'Mishal K.',
            'thumbnail': 're:^https?://media.licdn.com/dms/image/.*$',
            'like_count': int
        },
    }, {
        '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):