0

I have been downloading zip files from Google Drive. The files contain mp4 videos, and I didn't want to wait for the download to finish. VLC could play incomplete files just fine, but then the downloaded files are zip files, not mp4 files. wget is probably the easiest way to pipe a download directly to a filter, and then I could use funzip and output to a file, then play it as if streaming a video. However I couldn't get wget to download from Google Drive, it just kept returning ERROR 400 bad request error, same happened to curl, so I had to settle with Chromium. That way I would have to pipe from an incomplete file rather than a download.

Is there any simple way to use a file currently being downloaded for piping to funzip?

0
tail -n +0 -f /path/to/file | funzip ...

Basically, tail watches for changes in the length of the file and keeps streaming any additional bytes. However, it can't know when the download is finished, so it may be necessary to kill it at some point depending on what you are doing with the stream.

We assume, of course, that the browser is going to try and download the file linearly, and won't write any metadata to indicate that the file is only partially downloaded (that it would later overwrite with actual file bytes). In practice, the downloaders in browsers are pretty conservative, so this can be expected to work.

  • It would be good to include some explanation. Also, are you certain that Chromium's download mechanism writes a complete contiguous file from beginning to end? I don't know that all browsers' downloads work like that, but it's not really my area so it's possible that they do. – Wildcard Dec 7 '16 at 3:45
  • Why don't you just test it? – Julie Pelletier Dec 7 '16 at 4:48
  • @JuliePelletier That really sounds like a lot of work. Besides, the browser implementation can always change, there's not really a partial-download standard that the browser can be held to. – DepressedDaniel Dec 7 '16 at 5:06
  • tail -n +0 -f can be shortened to tail +0f – mik Jan 13 '17 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.