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

Code before:
        'url': 'https://drive.usercontent.google.com/download?id=0ByeS4oOUV-49Zzh4R1J6R09zazQ',
        'only_matching': True,
    }]

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        mobj = re.search(
            r'<iframe[^>]+src="https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9_-]{28,})',
            webpage)
        if mobj:
            yield 'https://drive.google.com/file/d/{}'.format(mobj.group('id'))

    @staticmethod
    def _construct_subtitle_url(base_url, video_id, language, fmt):
        return update_url_query(
            base_url, {
                'hl': 'en-US',
                'v': video_id,
                'type': 'track',
                'lang': language,
                'fmt': fmt,
            })

    def _get_subtitles(self, video_id, timed_text_base_url):
        subtitles = {}
        subtitle_data = self._download_xml(
            timed_text_base_url, video_id, 'Downloading subtitles XML', fatal=False, query={
                'hl': 'en-US',
                'type': 'list',
                'tlangs': 1,
                'v': video_id,
                'vssids': 1,
            })
        subtitle_formats = traverse_obj(subtitle_data, (lambda _, v: v.tag == 'format', {lambda x: x.get('fmt_code')}, {str}))
        for track in traverse_obj(subtitle_data, (lambda _, v: v.tag == 'track' and v.get('lang_code'))):
            language = track.get('lang_code')
            subtitles.setdefault(language, []).extend([{
                'url': self._construct_subtitle_url(timed_text_base_url, video_id, language, sub_fmt),
                'name': track.get('lang_original'),
                'ext': sub_fmt,
            } for sub_fmt in subtitle_formats])
        return subtitles

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = self._download_json(
            f'https://content-workspacevideo-pa.googleapis.com/v1/drive/media/{video_id}/playback',
            video_id, 'Downloading video webpage', query={'key': 'AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8'},
            headers={'Referer': 'https://drive.google.com/'})

        formats = []

Review comment (suggestion):
```suggestion
    def _get_subtitles(self, video_id, video_info):
        subtitles = {}
        timed_text_base_url = traverse_obj(video_info, ('timedTextDetails', 'timedTextBaseUrl', {url_or_none}))
        if not timed_text_base_url:
            return subtitles
        subtitle_data = self._download_xml(
```

Code after:
        'url': 'https://drive.usercontent.google.com/download?id=0ByeS4oOUV-49Zzh4R1J6R09zazQ',
        'only_matching': True,
    }]

    @classmethod
    def _extract_embed_urls(cls, url, webpage):
        mobj = re.search(
            r'<iframe[^>]+src="https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9_-]{28,})',
            webpage)
        if mobj:
            yield 'https://drive.google.com/file/d/{}'.format(mobj.group('id'))

    @staticmethod
    def _construct_subtitle_url(base_url, video_id, language, fmt):
        return update_url_query(
            base_url, {
                'hl': 'en-US',
                'v': video_id,
                'type': 'track',
                'lang': language,
                'fmt': fmt,
            })

    def _get_subtitles(self, video_id, video_info):
        subtitles = {}
        timed_text_base_url = traverse_obj(video_info, ('timedTextDetails', 'timedTextBaseUrl', {url_or_none}))
        if not timed_text_base_url:
            return subtitles
        subtitle_data = self._download_xml(
            timed_text_base_url, video_id, 'Downloading subtitles XML', fatal=False, query={
                'hl': 'en-US',
                'type': 'list',
                'tlangs': 1,
                'v': video_id,
                'vssids': 1,
            })
        subtitle_formats = traverse_obj(subtitle_data, (lambda _, v: v.tag == 'format', {lambda x: x.get('fmt_code')}, {str}))
        for track in traverse_obj(subtitle_data, (lambda _, v: v.tag == 'track' and v.get('lang_code'))):
            language = track.get('lang_code')
            subtitles.setdefault(language, []).extend([{
                'url': self._construct_subtitle_url(timed_text_base_url, video_id, language, sub_fmt),
                'name': track.get('lang_original'),
                'ext': sub_fmt,
            } for sub_fmt in subtitle_formats])
        return subtitles

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = self._download_json(
            f'https://content-workspacevideo-pa.googleapis.com/v1/drive/media/{video_id}/playback',
            video_id, 'Downloading video webpage', query={'key': 'AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8'},