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

progresshook on fragment.py: Inconsistent behavior on total_bytes #8711

Closed
zhuyifei1999 opened this issue Mar 1, 2016 · 3 comments
Closed

progresshook on fragment.py: Inconsistent behavior on total_bytes #8711

zhuyifei1999 opened this issue Mar 1, 2016 · 3 comments

Comments

@zhuyifei1999
Copy link

@zhuyifei1999 zhuyifei1999 commented Mar 1, 2016

In the documentation of progress_hooks, it's said that that if total_bytes is unknown, the value would be None:

    progress_hooks:    A list of functions that get called on download
                       progress, with a dictionary with the entries
                       * status: One of "downloading", "error", or "finished".
                                 Check this first and ignore unknown values.
                       If status is one of "downloading", or "finished", the
                       following properties may also be present:
...
                       * total_bytes: Size of the whole file, None if unknown

However this is not the case for fragment.py, where the key simply doesn't exist:

        # This dict stores the download progress, it's updated by the progress
        # hook
        state = {
            'status': 'downloading',
            'downloaded_bytes': 0,
            'frag_index': 0,
            'frag_count': total_frags,
            'filename': ctx['filename'],
            'tmpfilename': ctx['tmpfilename'],
        }

This has caused downstream issues such as KeyError: 'total_bytes'

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 1, 2016

the following properties may also be present:

None of these fields are guaranteed to be present at all. total_bytes is unknown beforehand for fragment based content. total_bytes_estimate may be available for non live streams.

@dstftw dstftw closed this Mar 1, 2016
@zhuyifei1999
Copy link
Author

@zhuyifei1999 zhuyifei1999 commented Mar 1, 2016

It may be None for unknown values, as explained so in docs, or the documentation itself is not consistent with the behavior.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Mar 1, 2016

It may be present or may not. If present it may contain a value or None. Unless mentioned otherwise, None is equivalent to absence of information.

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
2 participants
You can’t perform that action at this time.