Add config param for sync_favorites_default and cleanup command line arg

This commit is contained in:
Tim Rae
2024-06-09 08:46:54 +02:00
parent 6d6a4fe43e
commit 7a1343ac91
3 changed files with 21 additions and 8 deletions

View File

@@ -14,6 +14,11 @@ spotify:
#excluded_playlists:
# - spotify:playlist:1ABCDEqsABCD6EaABCDa0a
# default setting for syncing favorites when no command line arguments are provided
# - when true: favorites will be synced by default (overriden when any command line arg provided)
# - when false: favorites can only be synced manually via --sync-favorites argument
sync_favorites_default: true
# increasing these parameters should increase the search speed, while decreasing reduces likelihood of 429 errors
max_concurrency: 10 # max concurrent connections at any given time
rate_limit: 10 # max sustained connections per second

View File

@@ -30,6 +30,12 @@ You can also just synchronize a specific playlist by doing the following:
spotify_to_tidal --uri 1ABCDEqsABCD6EaABCDa0a # accepts playlist id or full playlist uri
```
or sync just your 'Liked Songs' with:
```bash
spotify_to_tidal --sync-favorites
```
See example_config.yml for more configuration options, and `spotify_to_tidal --help` for more options.
---

View File

@@ -9,8 +9,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--config', default='config.yml', help='location of the config file')
parser.add_argument('--uri', help='synchronize a specific URI instead of the one in the config')
parser.add_argument('--sync-favorites', action='store_true', help='synchronize the favorites')
parser.add_argument('--disable-favorites-sync', action='store_true', help='disable synchronization of favorites (only valid when no other args passed)') # todo: use subparser
parser.add_argument('--sync-favorites', action=argparse.BooleanOptionalAction, help='synchronize the favorites')
args = parser.parse_args()
with open(args.config, 'r') as f:
@@ -27,16 +26,19 @@ def main():
tidal_playlists = _sync.get_tidal_playlists_dict(tidal_session)
tidal_playlist = _sync.pick_tidal_playlist_for_spotify_playlist(spotify_playlist, tidal_playlists)
_sync.sync_playlists_wrapper(spotify_session, tidal_session, [tidal_playlist], config)
sync_favorites = args.sync_favorites # only sync favorites if command line argument explicitly passed
elif args.sync_favorites:
sync_favorites = True # sync only the favorites
elif config.get('sync_playlists', None):
# if the config contains a sync_playlists list of mappings then use that
_sync.sync_playlists_wrapper(spotify_session, tidal_session, _sync.get_playlists_from_config(spotify_session, tidal_session, config), config)
elif args.sync_favorites:
# sync just the favorites
_sync.sync_favorites_wrapper(spotify_session, tidal_session, config)
sync_favorites = args.sync_favorites is None and config.get('sync_favorites_default', True)
else:
# otherwise sync all the user playlists in the Spotify account and favorites if not disabled
# otherwise sync all the user playlists in the Spotify account and favorites unless explicitly disabled
_sync.sync_playlists_wrapper(spotify_session, tidal_session, _sync.get_user_playlist_mappings(spotify_session, tidal_session, config), config)
if not args.disable_favorites_sync:
sync_favorites = args.sync_favorites is None and config.get('sync_favorites_default', True)
if sync_favorites:
_sync.sync_favorites_wrapper(spotify_session, tidal_session, config)
if __name__ == '__main__':