'Download entry content and store in temporary folder.
Fails entry with a reason if there was problem.
:param bool require_path:
whether or not entries without \'path\' field are ignored
:param bool handle_magnets:
when used any of urls containing magnet link will replace url,
otherwise warning is printed.
:param fail_html:
fail entries which url respond with html content
:param tmp_path:
path to use for temporary files while downloading'

def get_temp_file(self, task, entry, require_path=False, handle_magnets=False, fail_html=True, tmp_path=tempfile.gettempdir()):

    if entry.get(u'urls'):
        urls = entry.get(u'urls')
    else:
        urls = [entry[u'url']]
    errors = []
    for url in urls:
        if url.startswith(u'magnet:'):
            if handle_magnets:
                log.debug(u'Accepting    magnet    url    for    %s', entry[u'title'])
                entry[u'url'] = url
                break
            else:
                log.warning(u"Can't    download    magnet    url")
                errors.append(u'Magnet    URL')
                continue
        if (require_path and (u'path' not in entry)):
            log.debug(u'Skipping    url    %s    because    there    is    no    path    for    download', url)
            continue
        error = self.process_entry(task, entry, url, tmp_path)
        html_mimes = [u'html', u'text/html']
        if ((entry.get(u'mime-type') in html_mimes) and fail_html):
            error = (u'Unexpected    html    content    received    from    `%s`    -    maybe    a    login    page?' % entry[u'url'])
            self.cleanup_temp_file(entry)
        if (not error):
            log.debug(u'Successfully    retrieved    %s    from    %s', entry[u'title'], url)
            entry[u'url'] = url
            break
        else:
            errors.append(error)
    else:
        if (require_path and (u'path' not in entry)):
            log.error(u"%s    can't    be    downloaded,    no    path    specified    for    entry", entry[u'title'])
            entry.fail(u'no    path    specified    for    entry')
        else:
            entry.fail(u',    '.join(errors))
