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

[downloader/fragment] Fix ETA calculation of resumed download #21992

Merged
merged 1 commit into from
Aug 10, 2019

Conversation

lightmare
Copy link
Contributor

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

When resuming a partially downloaded file with fragment (or derived) downloader, the displayed ETA is wildly inaccurate. This is because the call to calc_eta doesn't subtract the starting partial file size from total and current byte counters.

For example: I have 1000MB out of a 2000MB video downloaded (youtube-dl killed for some reason, e.g. I needed to reboot or download something more important quickly). Later I run youtube-dl again to finish the download and the speed is ~1MB/s. After 5 seconds elapsed, ETA shows 5 seconds remaining, because the rate inside calc_eta is 1005MB/5s (instead of 5MB/5s), and so it predicts the remaining 995MB will be downloaded in ~5s (instead of 995s).

This PR subtracts the starting partial file size from the ETA calculation, and thus makes the ETA somewhat useful when resuming a large partial download.

@dstftw dstftw merged commit 3bce4ff into ytdl-org:master Aug 10, 2019
@lightmare lightmare deleted the fix-fragment-eta branch August 11, 2019 09:44
@iG8R iG8R mentioned this pull request Aug 13, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants