mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 14:52:38 +00:00
[downloader/dash] Do not pollute ``self
``
This commit is contained in:
parent
0c8662d2b6
commit
93dfcb9357
@ -16,14 +16,14 @@ class DashSegmentsFD(FileDownloader):
|
|||||||
base_url = info_dict['url']
|
base_url = info_dict['url']
|
||||||
segment_urls = info_dict['segment_urls']
|
segment_urls = info_dict['segment_urls']
|
||||||
|
|
||||||
self.byte_counter = 0
|
byte_counter = 0
|
||||||
|
|
||||||
def append_url_to_file(outf, target_url, target_name):
|
def append_url_to_file(outf, target_url, target_name):
|
||||||
self.to_screen('[DashSegments] %s: Downloading %s' % (info_dict['id'], target_name))
|
self.to_screen('[DashSegments] %s: Downloading %s' % (info_dict['id'], target_name))
|
||||||
req = compat_urllib_request.Request(target_url)
|
req = compat_urllib_request.Request(target_url)
|
||||||
data = self.ydl.urlopen(req).read()
|
data = self.ydl.urlopen(req).read()
|
||||||
outf.write(data)
|
outf.write(data)
|
||||||
self.byte_counter += len(data)
|
return len(data)
|
||||||
|
|
||||||
def combine_url(base_url, target_url):
|
def combine_url(base_url, target_url):
|
||||||
if re.match(r'^https?://', 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']),
|
outf, combine_url(base_url, info_dict['initialization_url']),
|
||||||
'initialization segment')
|
'initialization segment')
|
||||||
for i, segment_url in enumerate(segment_urls):
|
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),
|
outf, combine_url(base_url, segment_url),
|
||||||
'segment %d / %d' % (i + 1, len(segment_urls)))
|
'segment %d / %d' % (i + 1, len(segment_urls)))
|
||||||
|
byte_counter += segment_len
|
||||||
|
|
||||||
self.try_rename(tmpfilename, filename)
|
self.try_rename(tmpfilename, filename)
|
||||||
|
|
||||||
self._hook_progress({
|
self._hook_progress({
|
||||||
'downloaded_bytes': self.byte_counter,
|
'downloaded_bytes': byte_counter,
|
||||||
'total_bytes': self.byte_counter,
|
'total_bytes': byte_counter,
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'status': 'finished',
|
'status': 'finished',
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user