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

Code before:
            login_submit_page, 'error', default=None)
        if error:
            raise ExtractorError(error, expected=True)


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',
        },
    }

    def json2srt(self, transcript_lines, duration=None):
        srt_data = ''
        for line, (line_dict, next_dict) in enumerate(zip_longest(transcript_lines, transcript_lines[1:])):
            start_time, caption = line_dict['transcriptStartAt'], line_dict['caption']
            end_time = next_dict['transcriptStartAt'] / 1000 if next_dict else duration if duration else ((start_time + 1000) / 1000)
            srt_data += '%d\n%s --> %s\n%s\n' % (line + 1, srt_subtitles_timecode(start_time / 1000),
                                                 srt_subtitles_timecode(end_time),
                                                 caption)
        return srt_data

    def _real_extract(self, url):
        course_slug, video_slug = self._match_valid_url(url).groups()

        video_data = None
        formats = []
        for width, height in ((640, 360), (960, 540), (1280, 720)):
            video_data = self._call_api(
                course_slug, 'selectedVideo', video_slug, height)['selectedVideo']

            video_url_data = video_data.get('url') or {}
            progressive_url = video_url_data.get('progressiveUrl')
            if progressive_url:
                formats.append({
                    'format_id': 'progressive-%dp' % height,
                    'url': progressive_url,
                    'ext': 'mp4',
                    'height': height,
                    'width': width,
                    'source_preference': 1,
                })


Review comment (suggestion):
```suggestion
            start_time, caption = line_dict['transcriptStartAt'] / 1000, line_dict['caption']
            end_time = next_dict['transcriptStartAt'] / 1000 if next_dict else duration or start_time + 1
            srt_data += '%d\n%s --> %s\n%s\n' % (line + 1, srt_subtitles_timecode(start_time),
```

Code after:
            login_submit_page, 'error', default=None)
        if error:
            raise ExtractorError(error, expected=True)


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',
        },
    }

    def json2srt(self, transcript_lines, duration=None):
        srt_data = ''
        for line, (line_dict, next_dict) in enumerate(zip_longest(transcript_lines, transcript_lines[1:])):
            start_time, caption = line_dict['transcriptStartAt'] / 1000, line_dict['caption']
            end_time = next_dict['transcriptStartAt'] / 1000 if next_dict else duration or start_time + 1
            srt_data += '%d\n%s --> %s\n%s\n' % (line + 1, srt_subtitles_timecode(start_time),
                                                 srt_subtitles_timecode(end_time),
                                                 caption)
        return srt_data

    def _real_extract(self, url):
        course_slug, video_slug = self._match_valid_url(url).groups()

        video_data = None
        formats = []
        for width, height in ((640, 360), (960, 540), (1280, 720)):
            video_data = self._call_api(
                course_slug, 'selectedVideo', video_slug, height)['selectedVideo']

            video_url_data = video_data.get('url') or {}
            progressive_url = video_url_data.get('progressiveUrl')
            if progressive_url:
                formats.append({
                    'format_id': 'progressive-%dp' % height,
                    'url': progressive_url,
                    'ext': 'mp4',
                    'height': height,
                    'width': width,
                    'source_preference': 1,
                })