'Take the result of the ie(may be modified) and resolve all unresolved
references (URLs, playlist items).
It will also download the videos if \'download\'.
Returns the resolved ie_result.'

def process_ie_result(self, ie_result, download=True, extra_info={}):

    result_type = ie_result.get(u'_type', u'video')
    if (result_type in (u'url', u'url_transparent')):
        ie_result[u'url'] = sanitize_url(ie_result[u'url'])
        extract_flat = self.params.get(u'extract_flat', False)
        if (((extract_flat == u'in_playlist') and (u'playlist' in extra_info)) or (extract_flat is True)):
            if self.params.get(u'forcejson', False):
                self.to_stdout(json.dumps(ie_result))
            return ie_result
    if (result_type == u'video'):
        self.add_extra_info(ie_result, extra_info)
        return self.process_video_result(ie_result, download=download)
    elif (result_type == u'url'):
        return self.extract_info(ie_result[u'url'], download, ie_key=ie_result.get(u'ie_key'), extra_info=extra_info)
    elif (result_type == u'url_transparent'):
        info = self.extract_info(ie_result[u'url'], ie_key=ie_result.get(u'ie_key'), extra_info=extra_info, download=False, process=False)
        if (not info):
            return info
        force_properties = dict(((k, v) for (k, v) in ie_result.items() if (v is not None)))
        for f in (u'_type', u'url', u'id', u'extractor', u'extractor_key', u'ie_key'):
            if (f in force_properties):
                del force_properties[f]
        new_result = info.copy()
        new_result.update(force_properties)
        if (new_result.get(u'_type') == u'url'):
            new_result[u'_type'] = u'url_transparent'
        return self.process_ie_result(new_result, download=download, extra_info=extra_info)
    elif (result_type in (u'playlist', u'multi_video')):
        playlist = (ie_result.get(u'title') or ie_result.get(u'id'))
        self.to_screen((u'[download]    Downloading    playlist:    %s' % playlist))
        playlist_results = []
        playliststart = (self.params.get(u'playliststart', 1) - 1)
        playlistend = self.params.get(u'playlistend')
        if (playlistend == (-1)):
            playlistend = None
        playlistitems_str = self.params.get(u'playlist_items')
        playlistitems = None
        if (playlistitems_str is not None):
            def iter_playlistitems(format):
                for string_segment in format.split(u','):
                    if (u'-' in string_segment):
                        (start, end) = string_segment.split(u'-')
                        for item in range(int(start), (int(end) + 1)):
                            (yield int(item))
                    else:
                        (yield int(string_segment))
            playlistitems = iter_playlistitems(playlistitems_str)
        ie_entries = ie_result[u'entries']
        if isinstance(ie_entries, list):
            n_all_entries = len(ie_entries)
            if playlistitems:
                entries = [ie_entries[(i - 1)] for i in playlistitems if ((- n_all_entries) <= (i - 1) < n_all_entries)]
            else:
                entries = ie_entries[playliststart:playlistend]
            n_entries = len(entries)
            self.to_screen((u'[%s]    playlist    %s:    Collected    %d    video    ids    (downloading    %d    of    them)' % (ie_result[u'extractor'], playlist, n_all_entries, n_entries)))
        elif isinstance(ie_entries, PagedList):
            if playlistitems:
                entries = []
                for item in playlistitems:
                    entries.extend(ie_entries.getslice((item - 1), item))
            else:
                entries = ie_entries.getslice(playliststart, playlistend)
            n_entries = len(entries)
            self.to_screen((u'[%s]    playlist    %s:    Downloading    %d    videos' % (ie_result[u'extractor'], playlist, n_entries)))
        else:
            if playlistitems:
                entry_list = list(ie_entries)
                entries = [entry_list[(i - 1)] for i in playlistitems]
            else:
                entries = list(itertools.islice(ie_entries, playliststart, playlistend))
            n_entries = len(entries)
            self.to_screen((u'[%s]    playlist    %s:    Downloading    %d    videos' % (ie_result[u'extractor'], playlist, n_entries)))
        if self.params.get(u'playlistreverse', False):
            entries = entries[::(-1)]
        if self.params.get(u'playlistrandom', False):
            random.shuffle(entries)
        x_forwarded_for = ie_result.get(u'__x_forwarded_for_ip')
        for (i, entry) in enumerate(entries, 1):
            self.to_screen((u'[download]    Downloading    video    %s    of    %s' % (i, n_entries)))
            if x_forwarded_for:
                entry[u'__x_forwarded_for_ip'] = x_forwarded_for
            extra = {u'n_entries': n_entries, u'playlist': playlist, u'playlist_id': ie_result.get(u'id'), u'playlist_title': ie_result.get(u'title'), u'playlist_index': (i + playliststart), u'extractor': ie_result[u'extractor'], u'webpage_url': ie_result[u'webpage_url'], u'webpage_url_basename': url_basename(ie_result[u'webpage_url']), u'extractor_key': ie_result[u'extractor_key']}
            reason = self._match_entry(entry, incomplete=True)
            if (reason is not None):
                self.to_screen((u'[download]    ' + reason))
                continue
            entry_result = self.process_ie_result(entry, download=download, extra_info=extra)
            playlist_results.append(entry_result)
        ie_result[u'entries'] = playlist_results
        self.to_screen((u'[download]    Finished    downloading    playlist:    %s' % playlist))
        return ie_result
    elif (result_type == u'compat_list'):
        self.report_warning((u'Extractor    %s    returned    a    compat_list    result.    It    needs    to    be    updated.' % ie_result.get(u'extractor')))
        def _fixup(r):
            self.add_extra_info(r, {u'extractor': ie_result[u'extractor'], u'webpage_url': ie_result[u'webpage_url'], u'webpage_url_basename': url_basename(ie_result[u'webpage_url']), u'extractor_key': ie_result[u'extractor_key']})
            return r
        ie_result[u'entries'] = [self.process_ie_result(_fixup(r), download, extra_info) for r in ie_result[u'entries']]
        return ie_result
    else:
        raise Exception((u'Invalid    result    type:    %s' % result_type))
