I found today I can download multiple files in a range using curl and this is great.
$ curl -O "http://example.com/[001-100].png"
(https://everything.curl.dev/cmdline/globbing)
Also I found I can use -f
flag to prevent saving empty files in case of missing (let's say we check all the files in range 001-100, but there are only files from 001 to 050).
The problem I have is my range is really large. I want to save some videos from an online streaming (and they are splits by ~5 seconds, to be merged in a single video later by my script). The range is kind of 00001-10000, but some videos are really short (00001-00100).
I need a way to stop the try-to-download video files, when the returned file is empty instead of ignoring this case. Kind of loop/break.
Is it possible with curl? Do you have any suggestion? (I just want to save all the video fragments that exists in that range 00001-10000, but stop the try-to-download when nothing more is found).
Update:
The context: a long video is split in small .ts and its fragments named with consecutive integers. If 070 is a valid file and 071 is an empty one, then it means the video has only 70 parts I will merge then. These are my final steps to get the video as a single file after downloading the parts.
$ printf "file '%s'\n" ./*.ts > mylist.txt
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy final-video.ts