From 8d11a8402f9127c205ad01372f03bc323b630cca Mon Sep 17 00:00:00 2001 From: nathom Date: Mon, 26 Jul 2021 21:17:00 -0700 Subject: [PATCH] Fix FileNotFoundError with Music.app auto folder --- streamrip/media.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/streamrip/media.py b/streamrip/media.py index c25ae3d..fcf65d4 100644 --- a/streamrip/media.py +++ b/streamrip/media.py @@ -343,8 +343,15 @@ class Track(Media): :type path: str """ os.makedirs(os.path.dirname(path), exist_ok=True) - shutil.copy(self.path, path) - os.remove(self.path) + + try: + shutil.move(self.path, path) + except FileNotFoundError as e: + # This sometimes happens when using Music.app's Auto folder + logger.debug("%s during shutil.move", e) + os.makedirs(os.path.dirname(path), exist_ok=True) + shutil.move(self.path, path) + self.path = path def _soundcloud_download(self, dl_info: dict):