Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
cli
Commits
d9468ff0
Verified
Commit
d9468ff0
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Support for ignoring errors when downloading tracks
parent
a8976e5f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
funkwhale_cli/cli.py
+15
-2
15 additions, 2 deletions
funkwhale_cli/cli.py
with
15 additions
and
2 deletions
funkwhale_cli/cli.py
+
15
−
2
View file @
d9468ff0
...
...
@@ -643,6 +643,8 @@ def flatten(d, parent_key="", sep="_"):
@click.option
(
"
--format
"
,
"
-f
"
)
@click.option
(
"
-d
"
,
"
--directory
"
,
type
=
click
.
Path
(
exists
=
True
))
@click.option
(
"
-o
"
,
"
--overwrite
"
,
is_flag
=
True
,
default
=
False
)
@click.option
(
"
-s
"
,
"
--skip-existing
"
,
is_flag
=
True
,
default
=
False
)
@click.option
(
"
-i
"
,
"
--ignore-errors
"
,
multiple
=
True
,
type
=
int
)
@click.option
(
"
-t
"
,
"
--template
"
,
...
...
@@ -651,7 +653,7 @@ def flatten(d, parent_key="", sep="_"):
)
@click.pass_context
@async_command
async
def
track_download
(
ctx
,
id
,
format
,
directory
,
template
,
overwrite
):
async
def
track_download
(
ctx
,
id
,
format
,
directory
,
template
,
overwrite
,
ignore_errors
,
skip_existing
):
async
with
ctx
.
obj
[
"
remote
"
]:
progressbar
=
tqdm
.
tqdm
(
id
,
unit
=
"
Files
"
)
for
i
in
progressbar
:
...
...
@@ -661,7 +663,14 @@ async def track_download(ctx, id, format, directory, template, overwrite):
logs
.
logger
.
info
(
"
Downloading from {}
"
.
format
(
download_url
))
response
=
await
ctx
.
obj
[
"
remote
"
].
request
(
"
get
"
,
download_url
,
timeout
=
0
)
try
:
response
.
raise_for_status
()
except
aiohttp
.
ClientResponseError
as
e
:
if
response
.
status
in
ignore_errors
:
logs
.
logger
.
warning
(
"
Remote answered with {} for url {}, skipping
"
.
format
(
response
.
status
,
download_url
))
continue
else
:
raise
click
.
ClickException
(
"
Remote answered with {} for url {}, exiting
"
.
format
(
response
.
status
,
download_url
))
filename_params
=
flatten
(
track_data
)
filename_params
[
"
album
"
]
=
filename_params
[
'
album_title
'
]
filename_params
[
"
artist
"
]
=
filename_params
[
'
artist_name
'
]
...
...
@@ -680,7 +689,11 @@ async def track_download(ctx, id, format, directory, template, overwrite):
final_directory
=
os
.
path
.
dirname
(
full_path
)
pathlib
.
Path
(
final_directory
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
logs
.
logger
.
info
(
"
Downloading to {}
"
.
format
(
full_path
))
if
not
overwrite
and
os
.
path
.
exists
(
full_path
):
existing
=
os
.
path
.
exists
(
full_path
)
if
skip_existing
and
existing
:
logs
.
logger
.
info
(
"'
{}
'
already exists on disk, skipping download
"
.
format
(
full_path
))
continue
elif
not
overwrite
and
existing
:
raise
click
.
ClickException
(
"'
{}
'
already exists on disk. Relaunch this command with --overwrite if you want to replace it
"
.
format
(
full_path
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment