Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in check of file path #95

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions pafy/pafy.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,18 +926,17 @@ def download(self, filepath="", quiet=False, callback=lambda *x: None,
"""
# pylint: disable=R0912,R0914
# Too many branches, too many local vars
savedir = filename = ""

if filepath and os.path.isdir(filepath):
savedir, filename = filepath, self.generate_filename()

elif filepath:
savedir, filename = os.path.split(filepath)

if filepath:
if os.path.exists(filepath):
if os.path.isdir(filepath):
filepath = os.path.join(filepath, self.generate_filename(meta=meta))
else:
path_dir = os.path.split(filepath)[0]
if path_dir and not os.path.exists(path_dir):
raise IOError('No such file or directory: ' + filepath)
else:
filename = self.generate_filename(meta=meta)

filepath = os.path.join(savedir, filename)
filepath = self.generate_filename(meta=meta)

temp_filepath = filepath + ".temp"

status_string = (' {:,} Bytes [{:.2%}] received. Rate: [{:4.0f} '
Expand Down