From 6095cc3ca397a3cc8e4f738857bc8d92f65ae49e Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Mon, 15 Apr 2024 22:59:14 +0200 Subject: [PATCH] SpotifyRecorder: add settings option to skip conformation --- SpotifyRecorder.py | 14 ++++++++++---- config/settings-recorder-example.json | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/SpotifyRecorder.py b/SpotifyRecorder.py index 7963fb1..c254397 100644 --- a/SpotifyRecorder.py +++ b/SpotifyRecorder.py @@ -27,7 +27,8 @@ class SpotifyRecorder: playlists: list[dict[str, str | int]], spotifyDeviceName: str, audioDeviceName: str, - destinationFolder: str): + destinationFolder: str, + skipConfirmation: bool): self._clientID = clientID self._clientSecret = clientSecret self._redirectUrl = redirectUrl @@ -37,6 +38,7 @@ class SpotifyRecorder: self._spotifyDeviceName = spotifyDeviceName self._audioDeviceName = audioDeviceName self._destinationFolder = destinationFolder + self._skipConfirmation = skipConfirmation os.makedirs(self._destinationFolder, exist_ok=True) @@ -76,9 +78,12 @@ class SpotifyRecorder: [track['track']['duration_ms'] // 1000 for track in tracks if not track['is_local']]) LOGGER.info(f'Total duration: {self.__convert_seconds_to_duration(totalDurationInSeconds)}') - if click.confirm('Do you want to start recording?', default=True): - destinationFolder = os.path.join(self._destinationFolder, playlistSettings['name']) - os.makedirs(destinationFolder, exist_ok=True) + destinationFolder = os.path.join(self._destinationFolder, playlistSettings['name']) + os.makedirs(destinationFolder, exist_ok=True) + + if self._skipConfirmation: + self.__record_tracks(tracks, startNumber, destinationFolder) + elif click.confirm('Do you want to start recording?', default=True): self.__record_tracks(tracks, startNumber, destinationFolder) else: LOGGER.warning('Aborted') @@ -299,6 +304,7 @@ if __name__ == '__main__': SETTINGS['spotifyDeviceName'], SETTINGS['audioDeviceName'], SETTINGS['destinationFolder'], + SETTINGS['skipConfirmation'], ) spotifyBackup.run() diff --git a/config/settings-recorder-example.json b/config/settings-recorder-example.json index 3786cd0..39e81b9 100644 --- a/config/settings-recorder-example.json +++ b/config/settings-recorder-example.json @@ -17,5 +17,6 @@ "destinationFolder": "", "redirectUrl": "http://localhost:8080", "openBrowser": false, - "cacheFilePath": ".cache" + "cacheFilePath": ".cache", + "skipConfirmation": false } \ No newline at end of file -- GitLab