From 098554744a7239bc37ed96b8a2d575b24f5eb714 Mon Sep 17 00:00:00 2001
From: EorlBruder <eorl@bruder.space>
Date: Thu, 17 Jun 2021 08:10:14 +0000
Subject: [PATCH] Don't abort whole download, when one file doesn't exist

---
 funkwhale_cli/cli/tracks.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/funkwhale_cli/cli/tracks.py b/funkwhale_cli/cli/tracks.py
index 7433338..ba9e37d 100644
--- a/funkwhale_cli/cli/tracks.py
+++ b/funkwhale_cli/cli/tracks.py
@@ -36,10 +36,10 @@ async def get_track_download_url(id, remote, format=None):
         download_url = payload["uploads"][0]["listen_url"]
     except IndexError:
         if remote.token:
-            raise click.ClickException("This file is not available for download")
+            raise click.ClickException("This file is not available for download: " + id)
         else:
             raise click.ClickException(
-                "This file is not available for download, try to login first"
+                "This file is not available for download, try to login first: " + id
             )
 
     if download_url.startswith("/"):
@@ -73,9 +73,13 @@ async def track_download(
     async with ctx.obj["remote"]:
         progressbar = tqdm.tqdm(id, unit="Files")
         for i in progressbar:
-            download_url, format, track_data = await get_track_download_url(
-                i, ctx.obj["remote"], format=format
-            )
+            try:
+                download_url, format, track_data = await get_track_download_url(
+                    i, ctx.obj["remote"], format=format
+                )
+            except click.ClickException as e:
+                logs.logger.error(e.message)
+                continue
             logs.logger.info("Downloading from {}".format(download_url))
 
             filename_params = utils.flatten(track_data)
-- 
GitLab