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

Code before:
                caption_format_data.append({
                    'url': update_url_query(self._BASE_URL_CAPTIONS, query),
                    'ext': caption_format,
                })
            captions[caption_lang_code] = caption_format_data
        return captions

    def _get_subtitles(self, video_id, subtitles_id, hl):
        if not subtitles_id or not hl:
            return
        self._download_subtitles_xml(video_id, subtitles_id, hl)
        if not self._captions_xml:
            return
        return self._get_captions_by_type(video_id, subtitles_id, 'subtitles')

    def _get_automatic_captions(self, video_id, subtitles_id, hl):
        if not subtitles_id or not hl:
            return
        self._download_subtitles_xml(video_id, subtitles_id, hl)
        if not self._captions_xml:
            return
        track = None
        for t in self._captions_xml.findall('track'):
            if t.attrib.get('cantran') == 'true':
                track = t
                break
        if track is None:
            return
        origin_lang_code = track.attrib.get('lang_code')
        origin_lang_name = track.attrib.get('name')
        if not origin_lang_code or not origin_lang_name:
            return
        return self._get_captions_by_type(
            video_id, subtitles_id, 'automatic_captions', origin_lang_code, origin_lang_name)

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = urllib.parse.parse_qs(self._download_webpage(
            'https://drive.google.com/get_video_info',
            video_id, 'Downloading video webpage', query={'docid': video_id}))

        def get_value(key):
            return try_get(video_info, lambda x: x[key][0])

        reason = get_value('reason')
        title = get_value('title')

        formats = []
        fmt_stream_map = (get_value('fmt_stream_map') or '').split(',')
        fmt_list = (get_value('fmt_list') or '').split(',')
        if fmt_stream_map and fmt_list:

Review comment (suggestion):
```suggestion
        track = next((t for t in self._captions_xml.findall('track') if t.attrib.get('cantran') == 'true'), None)
```

Code after:
                caption_format_data.append({
                    'url': update_url_query(self._BASE_URL_CAPTIONS, query),
                    'ext': caption_format,
                })
            captions[caption_lang_code] = caption_format_data
        return captions

    def _get_subtitles(self, video_id, subtitles_id, hl):
        if not subtitles_id or not hl:
            return
        self._download_subtitles_xml(video_id, subtitles_id, hl)
        if not self._captions_xml:
            return
        return self._get_captions_by_type(video_id, subtitles_id, 'subtitles')

    def _get_automatic_captions(self, video_id, subtitles_id, hl):
        if not subtitles_id or not hl:
            return
        self._download_subtitles_xml(video_id, subtitles_id, hl)
        if not self._captions_xml:
            return
        track = next((t for t in self._captions_xml.findall('track') if t.attrib.get('cantran') == 'true'), None)
        if track is None:
            return
        origin_lang_code = track.attrib.get('lang_code')
        origin_lang_name = track.attrib.get('name')
        if not origin_lang_code or not origin_lang_name:
            return
        return self._get_captions_by_type(
            video_id, subtitles_id, 'automatic_captions', origin_lang_code, origin_lang_name)

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = urllib.parse.parse_qs(self._download_webpage(
            'https://drive.google.com/get_video_info',
            video_id, 'Downloading video webpage', query={'docid': video_id}))

        def get_value(key):
            return try_get(video_info, lambda x: x[key][0])

        reason = get_value('reason')
        title = get_value('title')

        formats = []
        fmt_stream_map = (get_value('fmt_stream_map') or '').split(',')
        fmt_list = (get_value('fmt_list') or '').split(',')
        if fmt_stream_map and fmt_list:
            resolutions = {}
            for fmt in fmt_list:
                mobj = re.search(
                    r'^(?P<format_id>\d+)/(?P<width>\d+)[xX](?P<height>\d+)', fmt)