Skip to content

Commit

Permalink
Tweaks to _youtubedl_download
Browse files Browse the repository at this point in the history
  • Loading branch information
vn-ki committed Mar 9, 2018
1 parent 9e5eaf9 commit e80e993
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pafy/backend_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ def download(self, *args, **kwargs):
def _youtubedl_download(self, filepath="", quiet=False, progress="Bytes",
callback=None, meta=False, remux_audio=False):

downloader = youtube_dl.downloader.http.HttpFD(ydl(),
{'http_chunk_size': 10240})
downloader = youtube_dl.downloader.http.HttpFD(ydl(), {})
# {'http_chunk_size': 5120})

progress_available = ["KB", "MB", "GB"]
if progress not in progress_available:
Expand All @@ -597,8 +597,14 @@ def progress_hook(s):
if s['status'] == 'downloading':
bytesdone = s['downloaded_bytes']
total = s['total_bytes']
rate = s['speed']/1024
eta = s['eta']
if s.get('speed') is not None:
rate = s['speed']/1024
else:
rate = 0
if s.get('eta') is None:
eta = 0
else:
eta = s['eta']

if progress == "KB":
progress_stats = (round(bytesdone/1024.0, 2),
Expand Down Expand Up @@ -639,7 +645,7 @@ def progress_hook(s):

infodict = {'url': self.url}

downloader.real_download(filename, infodict)
downloader.download(filename, infodict)

if remux_audio and self.mediatype == "audio":
subprocess.run("mv {} {}.temp".format(filepath))
Expand Down Expand Up @@ -752,8 +758,6 @@ def _internal_download(self, filepath="", quiet=False, progress="Bytes", callbac
return temp_filepath




def remux(infile, outfile, quiet=False, muxer="ffmpeg"):
""" Remux audio. """
muxer = muxer if isinstance(muxer, str) else "ffmpeg"
Expand Down

0 comments on commit e80e993

Please sign in to comment.