Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The progress hooks are not passed the file info when it already exists #3916

Closed
mdawar opened this issue Oct 10, 2014 · 0 comments
Closed

The progress hooks are not passed the file info when it already exists #3916

mdawar opened this issue Oct 10, 2014 · 0 comments

Comments

@mdawar
Copy link
Contributor

@mdawar mdawar commented Oct 10, 2014

I opened this issue to describe what I'm trying to solve in this pull request #3829.

When we add a progress hook using YoutubeDL.add_progress_hook, to be able to get the download info dict from the HttpFD class which looks like this:

self._hook_progress({
    'downloaded_bytes': byte_counter,
    'total_bytes': data_len,
    'tmpfilename': tmpfilename,
    'filename': filename,
    'status': 'downloading',
    'eta': eta,
    'speed': speed,
})

This info dict is passed to the progress hooks only in these cases:

  • Download in progress
  • Download finished
  • The file exists and continuedl is True and we're using .part files

But we don't get this dict when nooverwrites is True and the file exists, which I think is the same as when continuedl is True, so what's preventing the hooks from getting the info dict is this check inside YoutubeDL.process_info:

if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(filename)):
    success = True

If we let FileDownloader.download handle this check, this problem will be solved:

def download(self, filename, info_dict):
    """Download to a filename using the info from info_dict
    Return True on success and False otherwise
    """
    # TODO: Check here for nooverwrites and if the file exists
    if self.params.get('continuedl', False) and os.path.isfile(encodeFilename(filename)) and not self.params.get('nopart', False):
        self.report_file_already_downloaded(filename)
        self._hook_progress({
            'filename': filename,
            'status': 'finished',
            'total_bytes': os.path.getsize(encodeFilename(filename)),
        })
        return True

    return self.real_download(filename, info_dict)

So this pull request #3829 fixes this problem.

@jaimeMF jaimeMF closed this in 4340dec Jan 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.