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

Code before:
            'id': '27-02energyfreedombyenergyclub7295762520814874625',
            'ext': 'mp4',
            'title': '27.02 Energy Freedom by Energy Club',
            'description': 'md5:1292e6f31df998914c293787a02c3b91',
            'duration': 6420,
            'timestamp': 1739445333,
            'upload_date': '20250213',
        },
    }]

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

        base_data = traverse_obj(webpage, (
            {find_elements(tag='code', attr='style', value='display: none')}, ..., {json.loads}, 'included', ...))
        player_data = traverse_obj(base_data, (
            lambda _, v: v['$type'] == 'com.linkedin.videocontent.VideoPlayMetadata', any, {require('player metadata')}))
        meta_data = traverse_obj(base_data, (
            lambda _, v: v['$type'] == 'com.linkedin.voyager.dash.events.ProfessionalEvent', any))

        formats = []
        for prog_fmts in traverse_obj(player_data, ('progressiveStreams', ..., {dict})):
            for url in traverse_obj(prog_fmts, ('streamingLocations', ..., 'url', {url_or_none})):
                formats.append({
                    'url': url,
                    **traverse_obj(prog_fmts, {
                        'width': ('width', {int_or_none}),
                        'height': ('height', {int_or_none}),
                        'tbr': ('bitRate', {int_or_none(scale=1000)}),
                        'filesize': ('size', {int_or_none}),
                        'ext': ('mediaType', {mimetype2ext}),
                    }),
                })

        for m3u8_url in traverse_obj(player_data, (
            'adaptiveStreams', lambda _, v: v['protocol'] == 'HLS', 'masterPlaylists', ..., 'url', {url_or_none},
        )):
            formats.extend(self._extract_m3u8_formats(
                m3u8_url, event_id, 'mp4', m3u8_id='hls', fatal=False))

        return {
            'id': event_id,
            'formats': formats,
            **traverse_obj(player_data, {
                'duration': ('duration', {int_or_none(scale=1000)}),
                'timestamp': ('liveStreamCreatedAt', {int_or_none(scale=1000)}),
            }),
            **traverse_obj(meta_data, {
                'title': ('name', {str}),
                'description': ('description', 'text', {str}),

Review comment (suggestion):
I don't like reusing `url`
```suggestion
            for fmt_url in traverse_obj(prog_fmts, ('streamingLocations', ..., 'url', {url_or_none})):
                formats.append({
                    'url': fmt_url,
```

Code after:
    }, {
        'url': 'https://www.linkedin.com/events/27-02energyfreedombyenergyclub7295762520814874625/comments/',
        'info_dict': {
            'id': '27-02energyfreedombyenergyclub7295762520814874625',
            'ext': 'mp4',
            'title': '27.02 Energy Freedom by Energy Club',
            'description': 'md5:1292e6f31df998914c293787a02c3b91',
            'duration': 6420,
            'timestamp': 1739445333,
            'upload_date': '20250213',
            'release_timestamp': 1740657620,
            'release_date': '20250227',
            'live_status': 'was_live',
        },
    }]

    def _real_initialize(self):
        if not self._get_cookies('https://www.linkedin.com/').get('li_at'):
            self.raise_login_required()

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

        base_data = traverse_obj(webpage, (
            {find_elements(tag='code', attr='style', value='display: none')}, ..., {json.loads}, 'included', ...))
        meta_data = traverse_obj(base_data, (
            lambda _, v: v['$type'] == 'com.linkedin.voyager.dash.events.ProfessionalEvent', any)) or {}

        live_status = {
            'PAST': 'was_live',
            'ONGOING': 'is_live',
            'FUTURE': 'is_upcoming',
        }.get(meta_data.get('lifecycleState'))

        if live_status == 'is_upcoming':
            player_data = {}
            if event_time := traverse_obj(meta_data, ('displayEventTime', {str})):
                message = f'This live event is scheduled for {event_time}'
            else:
                message = 'This live event has not yet started'
            self.raise_no_formats(message, expected=True, video_id=event_id)
        else:
            # TODO: Add support for audio-only live events
            player_data = traverse_obj(base_data, (
                lambda _, v: v['$type'] == 'com.linkedin.videocontent.VideoPlayMetadata',
                any, {require('video player data')}))

        formats, subtitles = [], {}
        for prog_fmts in traverse_obj(player_data, ('progressiveStreams', ..., {dict})):
            for fmt_url in traverse_obj(prog_fmts, ('streamingLocations', ..., 'url', {url_or_none})):