-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
set mtime for fragmented videos (such as DASH) #27138
Conversation
- it is set to the mtime of the last fragment uploaded
This will set mtime for the final file number-of-fragment times. This is completely useless. mtime must be set one single time. |
Agreed. Although the mtime of the last fragment is what is effective after the download is complete.
Is the call to os.utime() for each fragment really that expensive? I agree it would be more efficient to do it only once.
Because that's the last time the file was modified. I.e. when the last fragment finally uploaded. |
- cleaner solution, only call os.utime() after last fragment
OK @dstftw take another look at this PR. Indeed FileDownloader already calls os.utime() on every fragment, so there's no point in doing it twice on every fragment. I've stuffed it into a variable on the FragmentFD class. And now the syscall is just done once in _finish_frag_download(). |
@dstftw BTW, it already calls os.utime() on every fragment here: youtube-dl/youtube_dl/downloader/common.py Line 222 in 2cd43a0
This is in FileDownloader.try_utime() called from HttpFD.download(). And in this case of fragmented files it's just as wasteful, since we only need the mtime of the last fragment. If you are truly concerned with eliminating wasteful syscalls, we should fix this too. |
@@ -116,6 +116,7 @@ def _append_fragment(self, ctx, frag_content): | |||
finally: | |||
if self.__do_ytdl_file(ctx): | |||
self._write_ytdl_file(ctx) | |||
self.mtime = os.stat(ctx['fragment_filename_sanitized']).st_mtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing conceptually changed: you still request st_mtime
unnecessarily n-1 times.
Calling |
…nt's Last-Modified header (closes ytdl-org#11718, closes ytdl-org#18384, closes ytdl-org#27138)
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:
What is the purpose of your pull request?
Description of your pull request and other information
set mtime for fragmented videos (such as DASH)
See issue #18384.