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

Max simultaneous downloads #83

Open
FredNieman opened this issue Jul 29, 2024 · 2 comments
Open

Max simultaneous downloads #83

FredNieman opened this issue Jul 29, 2024 · 2 comments

Comments

@FredNieman
Copy link

I've never been able to use this software to download a video more than a few seconds long. This is because when there are 100s of segments to download, a handful invariably fail. As there doesn't seem to be a way of detecting/retrying only the failed segments, my only option is to restart from scratch, where there will be a different handful of failed segments.

Sure, I can cobble together a full set of good segments across multiple attempts and write my own script to concatenate them together, but this is inefficient and I think it would be nice if users didn't have to do this. I suspect the easiest solution would be to limit max simultaneous downloads, downloading later segments only when the easier segments have finished so as to leave no segment behind.

@1gintonic
Copy link
Contributor

can you please report how to reproduce this issue as I can download vids with a length of 20min and more without issues.

@Gnuclear
Copy link

Gnuclear commented Sep 28, 2024

This is just a guess at what could be causing his issue:

The script downloads the video segments, merges the segments, and then deletes the segments.

If you have an explorer window open with the folder it's downloading the videos into, Windows will automatically generate thumbnails of the video segments.

But if the script tries to delete a segment while Windows is generating a thumbnail for it, the deletion fails.

I worked around this by making a wrapper function that waits and retries the file deletion:

def unlink_file(file):
    attempt = 0
    
    while True:
        attempt += 1
        
        try:
            file.unlink(missing_ok=True)
            break
        
        except PermissionError:
            if attempt > 10:
                raise
            
            sleep(attempt)

and then replacing file.unlink calls with calls to this wrapper function inside /download/m3u8.py as well as /fileio/dedupe.py

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

No branches or pull requests

3 participants