diff --git a/SpotifyRecorder.py b/SpotifyRecorder.py index 7963fb16da94bc2e85c5ce5bc2ed56a299086436..c254397c8eb68ffcf66827cd53673c1e012c5aef 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 3786cd0d0b5aad42cb25d5fe90e3959467239f5a..39e81b99374c79a55def80d2e273af4b4351d51a 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