Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ Authenticated file download

```bash
fync-get <URL>
fync-get --update <URL>
```

For example, you can download using **Bearer** or **Basic Authentication**.

```bash
fync-get https://httpbin.org/bearer
fync-get https://httpbin.org/basic-auth/test-user/test-password
```
9 changes: 6 additions & 3 deletions src/fync/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def url_request(url, opener):
if not filename:
parsed_url = urllib.parse.urlparse(url)
filename = os.path.basename(parsed_url.path)

if not filename:
filename = 'download'
filename_to_use = filename
postfix_num = 1
while os.path.exists(filename_to_use):
Expand All @@ -40,9 +41,11 @@ def url_request(url, opener):
shutil.move(temporary_filename, filename_to_use)
return filename_to_use
except urllib.error.URLError as e:
print(f'Error downloading {url}: {e}')
print(f'- Error downloading {url}: {e}')
except PermissionError as e:
print(f'Error Permission handling: {e}')
print(f'- Error downloading {url}: {e}')
except ValueError as e:
print(f'- Error downloading {url}: {e}')
finally:
if os.path.exists(temp_file.name):
os.unlink(temp_file.name)
Expand Down