Skip to content
Snippets Groups Projects
Commit 6095cc3c authored by Robert Goldmann's avatar Robert Goldmann
Browse files

SpotifyRecorder: add settings option to skip conformation

parent e20bb5df
Branches
Tags
No related merge requests found
...@@ -27,7 +27,8 @@ class SpotifyRecorder: ...@@ -27,7 +27,8 @@ class SpotifyRecorder:
playlists: list[dict[str, str | int]], playlists: list[dict[str, str | int]],
spotifyDeviceName: str, spotifyDeviceName: str,
audioDeviceName: str, audioDeviceName: str,
destinationFolder: str): destinationFolder: str,
skipConfirmation: bool):
self._clientID = clientID self._clientID = clientID
self._clientSecret = clientSecret self._clientSecret = clientSecret
self._redirectUrl = redirectUrl self._redirectUrl = redirectUrl
...@@ -37,6 +38,7 @@ class SpotifyRecorder: ...@@ -37,6 +38,7 @@ class SpotifyRecorder:
self._spotifyDeviceName = spotifyDeviceName self._spotifyDeviceName = spotifyDeviceName
self._audioDeviceName = audioDeviceName self._audioDeviceName = audioDeviceName
self._destinationFolder = destinationFolder self._destinationFolder = destinationFolder
self._skipConfirmation = skipConfirmation
os.makedirs(self._destinationFolder, exist_ok=True) os.makedirs(self._destinationFolder, exist_ok=True)
...@@ -76,9 +78,12 @@ class SpotifyRecorder: ...@@ -76,9 +78,12 @@ class SpotifyRecorder:
[track['track']['duration_ms'] // 1000 for track in tracks if not track['is_local']]) [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)}') 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'])
destinationFolder = os.path.join(self._destinationFolder, playlistSettings['name']) os.makedirs(destinationFolder, exist_ok=True)
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) self.__record_tracks(tracks, startNumber, destinationFolder)
else: else:
LOGGER.warning('Aborted') LOGGER.warning('Aborted')
...@@ -299,6 +304,7 @@ if __name__ == '__main__': ...@@ -299,6 +304,7 @@ if __name__ == '__main__':
SETTINGS['spotifyDeviceName'], SETTINGS['spotifyDeviceName'],
SETTINGS['audioDeviceName'], SETTINGS['audioDeviceName'],
SETTINGS['destinationFolder'], SETTINGS['destinationFolder'],
SETTINGS['skipConfirmation'],
) )
spotifyBackup.run() spotifyBackup.run()
......
...@@ -17,5 +17,6 @@ ...@@ -17,5 +17,6 @@
"destinationFolder": "", "destinationFolder": "",
"redirectUrl": "http://localhost:8080", "redirectUrl": "http://localhost:8080",
"openBrowser": false, "openBrowser": false,
"cacheFilePath": ".cache" "cacheFilePath": ".cache",
"skipConfirmation": false
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment