mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-29 14:54:14 +09:00
fix: add not function to return value(0 is normal); add total_seconds to download.eta(timedelta object); add waiting status when hook progress
This commit is contained in:
parent
af0aee79e7
commit
f7920e0449
@ -221,6 +221,7 @@ class Aria2pFD(ExternalFD):
|
|||||||
return cls.__avail
|
return cls.__avail
|
||||||
|
|
||||||
def _call_downloader(self, tmpfilename, info_dict):
|
def _call_downloader(self, tmpfilename, info_dict):
|
||||||
|
import aria2p
|
||||||
aria2 = aria2p.API(
|
aria2 = aria2p.API(
|
||||||
aria2p.Client(
|
aria2p.Client(
|
||||||
host='http://localhost',
|
host='http://localhost',
|
||||||
@ -246,22 +247,21 @@ class Aria2pFD(ExternalFD):
|
|||||||
download = aria2.add_uris([info_dict['url']], options)
|
download = aria2.add_uris([info_dict['url']], options)
|
||||||
status = {
|
status = {
|
||||||
'status': 'downloading',
|
'status': 'downloading',
|
||||||
'filename': self.__filename,
|
|
||||||
'tmpfilename': tmpfilename,
|
'tmpfilename': tmpfilename,
|
||||||
}
|
}
|
||||||
started = time.time()
|
started = time.time()
|
||||||
while download.status == 'active':
|
while download.status in ['active', 'waiting'] :
|
||||||
download = aria2.get_download(download.gid)
|
download = aria2.get_download(download.gid)
|
||||||
status.update({
|
status.update({
|
||||||
'downloaded_bytes': download.completed_length,
|
'downloaded_bytes': download.completed_length,
|
||||||
'total_bytes': download.total_length,
|
'total_bytes': download.total_length,
|
||||||
'elapsed': time.time() - started,
|
'elapsed': time.time() - started,
|
||||||
'eta': download.eta,
|
'eta': download.eta.total_seconds(),
|
||||||
'speed': download.download_speed,
|
'speed': download.download_speed,
|
||||||
})
|
})
|
||||||
self._hook_progress(status)
|
self._hook_progress(status)
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
return int(download.status == 'complete')
|
return not(download.status == 'complete')
|
||||||
|
|
||||||
|
|
||||||
class HttpieFD(ExternalFD):
|
class HttpieFD(ExternalFD):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user