'We need the webpage for getting the captions url, pass it as an
argument to speed up the process.'

def _get_automatic_captions(self, video_id, webpage):

    self.to_screen((u'%s:    Looking    for    automatic    captions' % video_id))
    player_config = self._get_ytplayer_config(video_id, webpage)
    err_msg = (u"Couldn't    find    automatic    captions    for    %s" % video_id)
    if (not player_config):
        self._downloader.report_warning(err_msg)
        return {}
    try:
        args = player_config[u'args']
        caption_url = args.get(u'ttsurl')
        if caption_url:
            timestamp = args[u'timestamp']
            list_params = compat_urllib_parse_urlencode({u'type': u'list', u'tlangs': 1, u'asrs': 1})
            list_url = ((caption_url + u'&') + list_params)
            caption_list = self._download_xml(list_url, video_id)
            original_lang_node = caption_list.find(u'track')
            if (original_lang_node is None):
                self._downloader.report_warning(u"Video    doesn't    have    automatic    captions")
                return {}
            original_lang = original_lang_node.attrib[u'lang_code']
            caption_kind = original_lang_node.attrib.get(u'kind', u'')
            sub_lang_list = {}
            for lang_node in caption_list.findall(u'target'):
                sub_lang = lang_node.attrib[u'lang_code']
                sub_formats = []
                for ext in self._SUBTITLE_FORMATS:
                    params = compat_urllib_parse_urlencode({u'lang': original_lang, u'tlang': sub_lang, u'fmt': ext, u'ts': timestamp, u'kind': caption_kind})
                    sub_formats.append({u'url': ((caption_url + u'&') + params), u'ext': ext})
                sub_lang_list[sub_lang] = sub_formats
            return sub_lang_list
        def make_captions(sub_url, sub_langs):
            parsed_sub_url = compat_urllib_parse_urlparse(sub_url)
            caption_qs = compat_parse_qs(parsed_sub_url.query)
            captions = {}
            for sub_lang in sub_langs:
                sub_formats = []
                for ext in self._SUBTITLE_FORMATS:
                    caption_qs.update({u'tlang': [sub_lang], u'fmt': [ext]})
                    sub_url = compat_urlparse.urlunparse(parsed_sub_url._replace(query=compat_urllib_parse_urlencode(caption_qs, True)))
                    sub_formats.append({u'url': sub_url, u'ext': ext})
                captions[sub_lang] = sub_formats
            return captions
        player_response = args.get(u'player_response')
        if (player_response and isinstance(player_response, compat_str)):
            player_response = self._parse_json(player_response, video_id, fatal=False)
            if player_response:
                renderer = player_response[u'captions'][u'playerCaptionsTracklistRenderer']
                base_url = renderer[u'captionTracks'][0][u'baseUrl']
                sub_lang_list = []
                for lang in renderer[u'translationLanguages']:
                    lang_code = lang.get(u'languageCode')
                    if lang_code:
                        sub_lang_list.append(lang_code)
                return make_captions(base_url, sub_lang_list)
        caption_tracks = args[u'caption_tracks']
        caption_translation_languages = args[u'caption_translation_languages']
        caption_url = compat_parse_qs(caption_tracks.split(u',')[0])[u'u'][0]
        sub_lang_list = []
        for lang in caption_translation_languages.split(u','):
            lang_qs = compat_parse_qs(compat_urllib_parse_unquote_plus(lang))
            sub_lang = lang_qs.get(u'lc', [None])[0]
            if sub_lang:
                sub_lang_list.append(sub_lang)
        return make_captions(caption_url, sub_lang_list)
    except (KeyError, IndexError, ExtractorError):
        self._downloader.report_warning(err_msg)
        return {}
