From 662972a116be78ff5917965d8611d0d90caa4853 Mon Sep 17 00:00:00 2001 From: xantares Date: Thu, 5 Feb 2015 08:29:51 +0100 Subject: [PATCH 1/8] [f4m] call progress hook --- youtube_dl/downloader/f4m.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 0e7a1c200..82c6ceec0 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -331,6 +331,14 @@ class F4mFD(FileDownloader): eta = self.calc_eta(start, time.time(), estimated_size, byte_counter) self.report_progress(progress, format_bytes(estimated_size), status.get('speed'), eta) + + # report totals to actual hooks + status['status'] = 'downloading' + #status['downloaded_bytes'] = state['downloaded_bytes'] ? + #status['total_bytes'] = ? + for hook in self._progress_hooks: + hook(status) + http_dl.add_progress_hook(frag_progress_hook) frags_filenames = [] From cdf5734829c832ea5bb2cc5635761e5599df9ca3 Mon Sep 17 00:00:00 2001 From: xantares Date: Sat, 14 Feb 2015 12:19:36 +0100 Subject: [PATCH 2/8] compute downloaded_bytes bytes --- youtube_dl/downloader/f4m.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 82c6ceec0..e4c123162 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -333,11 +333,12 @@ class F4mFD(FileDownloader): status.get('speed'), eta) # report totals to actual hooks - status['status'] = 'downloading' - #status['downloaded_bytes'] = state['downloaded_bytes'] ? - #status['total_bytes'] = ? + toplevel_status = {'status': 'downloading', 'filename': filename, 'tmpfilename': tmpfilename} + toplevel_status['downloaded_bytes'] = state['downloaded_bytes'] + if (state['downloaded_bytes'] > 0) and (progress > 0): + toplevel_status['total_bytes'] = int(100.0 * state['downloaded_bytes'] / progress) for hook in self._progress_hooks: - hook(status) + hook(toplevel_status) http_dl.add_progress_hook(frag_progress_hook) From f457fb5f01307f6ea71dd46eff829d9c99522e23 Mon Sep 17 00:00:00 2001 From: xantares Date: Mon, 16 Feb 2015 19:09:35 +0100 Subject: [PATCH 3/8] add speed & eta --- youtube_dl/downloader/f4m.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index e4c123162..a8a51546e 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -337,6 +337,10 @@ class F4mFD(FileDownloader): toplevel_status['downloaded_bytes'] = state['downloaded_bytes'] if (state['downloaded_bytes'] > 0) and (progress > 0): toplevel_status['total_bytes'] = int(100.0 * state['downloaded_bytes'] / progress) + if 'speed' in status: + toplevel_status['speed'] = status['speed'] + if 'eta' in status: + toplevel_status['eta'] = status['eta'] for hook in self._progress_hooks: hook(toplevel_status) From d837a0db4159fa80c74d42d51cbc3d013bcdef5d Mon Sep 17 00:00:00 2001 From: xantares Date: Mon, 16 Feb 2015 19:21:00 +0100 Subject: [PATCH 4/8] no need to check state['downloaded_bytes'] > 0 --- youtube_dl/downloader/f4m.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index a8a51546e..ddbcc5d1c 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -335,8 +335,10 @@ class F4mFD(FileDownloader): # report totals to actual hooks toplevel_status = {'status': 'downloading', 'filename': filename, 'tmpfilename': tmpfilename} toplevel_status['downloaded_bytes'] = state['downloaded_bytes'] - if (state['downloaded_bytes'] > 0) and (progress > 0): - toplevel_status['total_bytes'] = int(100.0 * state['downloaded_bytes'] / progress) + total_bytes = 0 + if progress > 0: + total_bytes = int((100.0 * state['downloaded_bytes']) / progress) + toplevel_status['total_bytes'] = total_bytes if 'speed' in status: toplevel_status['speed'] = status['speed'] if 'eta' in status: From 1da87389c6d24f4c8db3c38ed779a38610bf8063 Mon Sep 17 00:00:00 2001 From: xantares Date: Tue, 17 Feb 2015 20:04:43 +0100 Subject: [PATCH 5/8] use global eta --- youtube_dl/downloader/f4m.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index ddbcc5d1c..84e4a224d 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -342,7 +342,7 @@ class F4mFD(FileDownloader): if 'speed' in status: toplevel_status['speed'] = status['speed'] if 'eta' in status: - toplevel_status['eta'] = status['eta'] + toplevel_status['eta'] = eta for hook in self._progress_hooks: hook(toplevel_status) From 5be178bd1e6abbd68d6edded6d5abdd3e0b16591 Mon Sep 17 00:00:00 2001 From: xantares Date: Tue, 17 Feb 2015 20:05:34 +0100 Subject: [PATCH 6/8] use _hook_progress instead of loop --- youtube_dl/downloader/f4m.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 84e4a224d..45038186a 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -343,8 +343,7 @@ class F4mFD(FileDownloader): toplevel_status['speed'] = status['speed'] if 'eta' in status: toplevel_status['eta'] = eta - for hook in self._progress_hooks: - hook(toplevel_status) + self._hook_progress(toplevel_status) http_dl.add_progress_hook(frag_progress_hook) From 6c5b7e5885fc314240843773b2b7620f8e1468d3 Mon Sep 17 00:00:00 2001 From: xantares Date: Tue, 17 Feb 2015 20:08:04 +0100 Subject: [PATCH 7/8] do not test 'eta' in status --- youtube_dl/downloader/f4m.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 45038186a..12108d0f2 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -341,8 +341,7 @@ class F4mFD(FileDownloader): toplevel_status['total_bytes'] = total_bytes if 'speed' in status: toplevel_status['speed'] = status['speed'] - if 'eta' in status: - toplevel_status['eta'] = eta + toplevel_status['eta'] = eta self._hook_progress(toplevel_status) http_dl.add_progress_hook(frag_progress_hook) From 1270808b7c9812411a7436b2fef192af1e16f738 Mon Sep 17 00:00:00 2001 From: xantares Date: Tue, 17 Feb 2015 20:13:52 +0100 Subject: [PATCH 8/8] mention approximation --- youtube_dl/downloader/f4m.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/youtube_dl/downloader/f4m.py b/youtube_dl/downloader/f4m.py index 12108d0f2..235d06b4b 100644 --- a/youtube_dl/downloader/f4m.py +++ b/youtube_dl/downloader/f4m.py @@ -333,15 +333,16 @@ class F4mFD(FileDownloader): status.get('speed'), eta) # report totals to actual hooks - toplevel_status = {'status': 'downloading', 'filename': filename, 'tmpfilename': tmpfilename} + toplevel_status = {'status': 'downloading', 'filename': filename, + 'tmpfilename': tmpfilename, 'eta': eta} toplevel_status['downloaded_bytes'] = state['downloaded_bytes'] total_bytes = 0 if progress > 0: + # subject to rounding error total_bytes = int((100.0 * state['downloaded_bytes']) / progress) toplevel_status['total_bytes'] = total_bytes if 'speed' in status: toplevel_status['speed'] = status['speed'] - toplevel_status['eta'] = eta self._hook_progress(toplevel_status) http_dl.add_progress_hook(frag_progress_hook)