diff options
author | Tom-Oliver Heidel <github@tom-oliver.eu> | 2020-11-30 02:51:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 02:51:41 +0100 |
commit | b662fc8d2033c615ffbdd3b51123b446c03255e8 (patch) | |
tree | 3d32dc25a663f4e61fc28860acda67c7a425cb7a /youtube_dlc/downloader/fragment.py | |
parent | 8924ddc3eec4c03c6776673d0d5e823dc5445549 (diff) | |
parent | 929576bb9e4aa31f0516f1437d2ae762afdd9f2c (diff) | |
download | hypervideo-pre-b662fc8d2033c615ffbdd3b51123b446c03255e8.tar.lz hypervideo-pre-b662fc8d2033c615ffbdd3b51123b446c03255e8.tar.xz hypervideo-pre-b662fc8d2033c615ffbdd3b51123b446c03255e8.zip |
Merge branch 'master' into gedi
Diffstat (limited to 'youtube_dlc/downloader/fragment.py')
-rw-r--r-- | youtube_dlc/downloader/fragment.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/youtube_dlc/downloader/fragment.py b/youtube_dlc/downloader/fragment.py index 9339b3a62..cf4fd41da 100644 --- a/youtube_dlc/downloader/fragment.py +++ b/youtube_dlc/downloader/fragment.py @@ -97,12 +97,15 @@ class FragmentFD(FileDownloader): def _download_fragment(self, ctx, frag_url, info_dict, headers=None): fragment_filename = '%s-Frag%d' % (ctx['tmpfilename'], ctx['fragment_index']) - success = ctx['dl'].download(fragment_filename, { + fragment_info_dict = { 'url': frag_url, 'http_headers': headers or info_dict.get('http_headers'), - }) + } + success = ctx['dl'].download(fragment_filename, fragment_info_dict) if not success: return False, None + if fragment_info_dict.get('filetime'): + ctx['fragment_filetime'] = fragment_info_dict.get('filetime') down, frag_sanitized = sanitize_open(fragment_filename, 'rb') ctx['fragment_filename_sanitized'] = frag_sanitized frag_content = down.read() @@ -258,6 +261,13 @@ class FragmentFD(FileDownloader): downloaded_bytes = ctx['complete_frags_downloaded_bytes'] else: self.try_rename(ctx['tmpfilename'], ctx['filename']) + if self.params.get('updatetime', True): + filetime = ctx.get('fragment_filetime') + if filetime: + try: + os.utime(ctx['filename'], (time.time(), filetime)) + except Exception: + pass downloaded_bytes = os.path.getsize(encodeFilename(ctx['filename'])) self._hook_progress({ |