diff options
author | Yen Chi Hsuan <[email protected]> | 2015-06-10 13:44:54 +0800 |
---|---|---|
committer | Yen Chi Hsuan <[email protected]> | 2015-06-10 13:44:54 +0800 |
commit | 93dfcb9357b400b4d7e353d0a9db0e0194135b19 (patch) | |
tree | 7aed473bf51d207c16b991eacf68ac1e59517828 /youtube_dl/downloader/dash.py | |
parent | 0c8662d2b6f033ad42f1cc97989d4975629b524b (diff) | |
download | youtube-dl-93dfcb9357b400b4d7e353d0a9db0e0194135b19.tar.gz youtube-dl-93dfcb9357b400b4d7e353d0a9db0e0194135b19.zip |
[downloader/dash] Do not pollute ```self```
Diffstat (limited to 'youtube_dl/downloader/dash.py')
-rw-r--r-- | youtube_dl/downloader/dash.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/youtube_dl/downloader/dash.py b/youtube_dl/downloader/dash.py index 5f14658ba..cd84e0b07 100644 --- a/youtube_dl/downloader/dash.py +++ b/youtube_dl/downloader/dash.py @@ -16,14 +16,14 @@ class DashSegmentsFD(FileDownloader): base_url = info_dict['url'] segment_urls = info_dict['segment_urls'] - self.byte_counter = 0 + byte_counter = 0 def append_url_to_file(outf, target_url, target_name): self.to_screen('[DashSegments] %s: Downloading %s' % (info_dict['id'], target_name)) req = compat_urllib_request.Request(target_url) data = self.ydl.urlopen(req).read() outf.write(data) - self.byte_counter += len(data) + return len(data) def combine_url(base_url, target_url): if re.match(r'^https?://', target_url): @@ -35,15 +35,16 @@ class DashSegmentsFD(FileDownloader): outf, combine_url(base_url, info_dict['initialization_url']), 'initialization segment') for i, segment_url in enumerate(segment_urls): - append_url_to_file( + segment_len = append_url_to_file( outf, combine_url(base_url, segment_url), 'segment %d / %d' % (i + 1, len(segment_urls))) + byte_counter += segment_len self.try_rename(tmpfilename, filename) self._hook_progress({ - 'downloaded_bytes': self.byte_counter, - 'total_bytes': self.byte_counter, + 'downloaded_bytes': byte_counter, + 'total_bytes': byte_counter, 'filename': filename, 'status': 'finished', }) |