'Process a single resolved IE result.'

def process_info(self, info_dict):

    assert (info_dict.get(u'_type', u'video') == u'video')
    max_downloads = self.params.get(u'max_downloads')
    if (max_downloads is not None):
        if (self._num_downloads >= int(max_downloads)):
            raise MaxDownloadsReached()
    info_dict[u'fulltitle'] = info_dict[u'title']
    if (len(info_dict[u'title']) > 200):
        info_dict[u'title'] = (info_dict[u'title'][:197] + u'...')
    if (u'format' not in info_dict):
        info_dict[u'format'] = info_dict[u'ext']
    reason = self._match_entry(info_dict, incomplete=False)
    if (reason is not None):
        self.to_screen((u'[download]    ' + reason))
        return
    self._num_downloads += 1
    info_dict[u'_filename'] = filename = self.prepare_filename(info_dict)
    if self.params.get(u'forcetitle', False):
        self.to_stdout(info_dict[u'fulltitle'])
    if self.params.get(u'forceid', False):
        self.to_stdout(info_dict[u'id'])
    if self.params.get(u'forceurl', False):
        if (info_dict.get(u'requested_formats') is not None):
            for f in info_dict[u'requested_formats']:
                self.to_stdout((f[u'url'] + f.get(u'play_path', u'')))
        else:
            self.to_stdout((info_dict[u'url'] + info_dict.get(u'play_path', u'')))
    if (self.params.get(u'forcethumbnail', False) and (info_dict.get(u'thumbnail') is not None)):
        self.to_stdout(info_dict[u'thumbnail'])
    if (self.params.get(u'forcedescription', False) and (info_dict.get(u'description') is not None)):
        self.to_stdout(info_dict[u'description'])
    if (self.params.get(u'forcefilename', False) and (filename is not None)):
        self.to_stdout(filename)
    if (self.params.get(u'forceduration', False) and (info_dict.get(u'duration') is not None)):
        self.to_stdout(formatSeconds(info_dict[u'duration']))
    if self.params.get(u'forceformat', False):
        self.to_stdout(info_dict[u'format'])
    if self.params.get(u'forcejson', False):
        self.to_stdout(json.dumps(info_dict))
    if self.params.get(u'simulate', False):
        return
    if (filename is None):
        return
    try:
        dn = os.path.dirname(sanitize_path(encodeFilename(filename)))
        if (dn and (not os.path.exists(dn))):
            os.makedirs(dn)
    except (OSError, IOError) as err:
        self.report_error((u'unable    to    create    directory    ' + error_to_compat_str(err)))
        return
    if self.params.get(u'writedescription', False):
        descfn = replace_extension(filename, u'description', info_dict.get(u'ext'))
        if (self.params.get(u'nooverwrites', False) and os.path.exists(encodeFilename(descfn))):
            self.to_screen(u'[info]    Video    description    is    already    present')
        elif (info_dict.get(u'description') is None):
            self.report_warning(u"There's    no    description    to    write.")
        else:
            try:
                self.to_screen((u'[info]    Writing    video    description    to:    ' + descfn))
                with io.open(encodeFilename(descfn), u'w', encoding=u'utf-8') as descfile:
                    descfile.write(info_dict[u'description'])
            except (OSError, IOError):
                self.report_error((u'Cannot    write    description    file    ' + descfn))
                return
    if self.params.get(u'writeannotations', False):
        annofn = replace_extension(filename, u'annotations.xml', info_dict.get(u'ext'))
        if (self.params.get(u'nooverwrites', False) and os.path.exists(encodeFilename(annofn))):
            self.to_screen(u'[info]    Video    annotations    are    already    present')
        else:
            try:
                self.to_screen((u'[info]    Writing    video    annotations    to:    ' + annofn))
                with io.open(encodeFilename(annofn), u'w', encoding=u'utf-8') as annofile:
                    annofile.write(info_dict[u'annotations'])
            except (KeyError, TypeError):
                self.report_warning(u'There    are    no    annotations    to    write.')
            except (OSError, IOError):
                self.report_error((u'Cannot    write    annotations    file:    ' + annofn))
                return
    subtitles_are_requested = any([self.params.get(u'writesubtitles', False), self.params.get(u'writeautomaticsub')])
    if (subtitles_are_requested and info_dict.get(u'requested_subtitles')):
        subtitles = info_dict[u'requested_subtitles']
        ie = self.get_info_extractor(info_dict[u'extractor_key'])
        for (sub_lang, sub_info) in subtitles.items():
            sub_format = sub_info[u'ext']
            if (sub_info.get(u'data') is not None):
                sub_data = sub_info[u'data']
            else:
                try:
                    sub_data = ie._download_webpage(sub_info[u'url'], info_dict[u'id'], note=False)
                except ExtractorError as err:
                    self.report_warning((u'Unable    to    download    subtitle    for    "%s":    %s' % (sub_lang, error_to_compat_str(err.cause))))
                    continue
            try:
                sub_filename = subtitles_filename(filename, sub_lang, sub_format)
                if (self.params.get(u'nooverwrites', False) and os.path.exists(encodeFilename(sub_filename))):
                    self.to_screen((u'[info]    Video    subtitle    %s.%s    is    already_present' % (sub_lang, sub_format)))
                else:
                    self.to_screen((u'[info]    Writing    video    subtitles    to:    ' + sub_filename))
                    with io.open(encodeFilename(sub_filename), u'w', encoding=u'utf-8', newline=u'') as subfile:
                        subfile.write(sub_data)
            except (OSError, IOError):
                self.report_error((u'Cannot    write    subtitles    file    ' + sub_filename))
                return
    if self.params.get(u'writeinfojson', False):
        infofn = replace_extension(filename, u'info.json', info_dict.get(u'ext'))
        if (self.params.get(u'nooverwrites', False) and os.path.exists(encodeFilename(infofn))):
            self.to_screen(u'[info]    Video    description    metadata    is    already    present')
        else:
            self.to_screen((u'[info]    Writing    video    description    metadata    as    JSON    to:    ' + infofn))
            try:
                write_json_file(self.filter_requested_info(info_dict), infofn)
            except (OSError, IOError):
                self.report_error((u'Cannot    write    metadata    to    JSON    file    ' + infofn))
                return
    self._write_thumbnails(info_dict, filename)
    if (not self.params.get(u'skip_download', False)):
        try:
            def dl(name, info):
                fd = get_suitable_downloader(info, self.params)(self, self.params)
                for ph in self._progress_hooks:
                    fd.add_progress_hook(ph)
                if self.params.get(u'verbose'):
                    self.to_stdout((u'[debug]    Invoking    downloader    on    %r' % info.get(u'url')))
                return fd.download(name, info)
            if (info_dict.get(u'requested_formats') is not None):
                downloaded = []
                success = True
                merger = FFmpegMergerPP(self)
                if (not merger.available):
                    postprocessors = []
                    self.report_warning(u"You    have    requested    multiple    formats    but    ffmpeg    or    avconv    are    not    installed.    The    formats    won't    be    merged.")
                else:
                    postprocessors = [merger]
                def compatible_formats(formats):
                    (video, audio) = formats
                    (video_ext, audio_ext) = (audio.get(u'ext'), video.get(u'ext'))
                    if (video_ext and audio_ext):
                        COMPATIBLE_EXTS = ((u'mp3', u'mp4', u'm4a', u'm4p', u'm4b', u'm4r', u'm4v', u'ismv', u'isma'), u'webm')
                        for exts in COMPATIBLE_EXTS:
                            if ((video_ext in exts) and (audio_ext in exts)):
                                return True
                    return False
                filename_real_ext = os.path.splitext(filename)[1][1:]
                filename_wo_ext = (os.path.splitext(filename)[0] if (filename_real_ext == info_dict[u'ext']) else filename)
                requested_formats = info_dict[u'requested_formats']
                if ((self.params.get(u'merge_output_format') is None) and (not compatible_formats(requested_formats))):
                    info_dict[u'ext'] = u'mkv'
                    self.report_warning(u'Requested    formats    are    incompatible    for    merge    and    will    be    merged    into    mkv.')
                filename = (u'%s.%s' % (filename_wo_ext, info_dict[u'ext']))
                if os.path.exists(encodeFilename(filename)):
                    self.to_screen((u'[download]    %s    has    already    been    downloaded    and    merged' % filename))
                else:
                    for f in requested_formats:
                        new_info = dict(info_dict)
                        new_info.update(f)
                        fname = self.prepare_filename(new_info)
                        fname = prepend_extension(fname, (u'f%s' % f[u'format_id']), new_info[u'ext'])
                        downloaded.append(fname)
                        partial_success = dl(fname, new_info)
                        success = (success and partial_success)
                    info_dict[u'__postprocessors'] = postprocessors
                    info_dict[u'__files_to_merge'] = downloaded
            else:
                success = dl(filename, info_dict)
        except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
            self.report_error((u'unable    to    download    video    data:    %s' % error_to_compat_str(err)))
            return
        except (OSError, IOError) as err:
            raise UnavailableVideoError(err)
        except (ContentTooShortError,) as err:
            self.report_error((u'content    too    short    (expected    %s    bytes    and    served    %s)' % (err.expected, err.downloaded)))
            return
        if (success and (filename != u'-')):
            fixup_policy = self.params.get(u'fixup')
            if (fixup_policy is None):
                fixup_policy = u'detect_or_warn'
            INSTALL_FFMPEG_MESSAGE = u'Install    ffmpeg    or    avconv    to    fix    this    automatically.'
            stretched_ratio = info_dict.get(u'stretched_ratio')
            if ((stretched_ratio is not None) and (stretched_ratio != 1)):
                if (fixup_policy == u'warn'):
                    self.report_warning((u'%s:    Non-uniform    pixel    ratio    (%s)' % (info_dict[u'id'], stretched_ratio)))
                elif (fixup_policy == u'detect_or_warn'):
                    stretched_pp = FFmpegFixupStretchedPP(self)
                    if stretched_pp.available:
                        info_dict.setdefault(u'__postprocessors', [])
                        info_dict[u'__postprocessors'].append(stretched_pp)
                    else:
                        self.report_warning((u'%s:    Non-uniform    pixel    ratio    (%s).    %s' % (info_dict[u'id'], stretched_ratio, INSTALL_FFMPEG_MESSAGE)))
                else:
                    assert (fixup_policy in (u'ignore', u'never'))
            if ((info_dict.get(u'requested_formats') is None) and (info_dict.get(u'container') == u'm4a_dash')):
                if (fixup_policy == u'warn'):
                    self.report_warning((u'%s:    writing    DASH    m4a.    Only    some    players    support    this    container.' % info_dict[u'id']))
                elif (fixup_policy == u'detect_or_warn'):
                    fixup_pp = FFmpegFixupM4aPP(self)
                    if fixup_pp.available:
                        info_dict.setdefault(u'__postprocessors', [])
                        info_dict[u'__postprocessors'].append(fixup_pp)
                    else:
                        self.report_warning((u'%s:    writing    DASH    m4a.    Only    some    players    support    this    container.    %s' % (info_dict[u'id'], INSTALL_FFMPEG_MESSAGE)))
                else:
                    assert (fixup_policy in (u'ignore', u'never'))
            if ((info_dict.get(u'protocol') == u'm3u8_native') or ((info_dict.get(u'protocol') == u'm3u8') and self.params.get(u'hls_prefer_native'))):
                if (fixup_policy == u'warn'):
                    self.report_warning((u'%s:    malformed    AAC    bitstream    detected.' % info_dict[u'id']))
                elif (fixup_policy == u'detect_or_warn'):
                    fixup_pp = FFmpegFixupM3u8PP(self)
                    if fixup_pp.available:
                        info_dict.setdefault(u'__postprocessors', [])
                        info_dict[u'__postprocessors'].append(fixup_pp)
                    else:
                        self.report_warning((u'%s:    malformed    AAC    bitstream    detected.    %s' % (info_dict[u'id'], INSTALL_FFMPEG_MESSAGE)))
                else:
                    assert (fixup_policy in (u'ignore', u'never'))
            try:
                self.post_process(filename, info_dict)
            except PostProcessingError as err:
                self.report_error((u'postprocessing:    %s' % str(err)))
                return
            self.record_download_archive(info_dict)
