Add config param for sync_favorites_default and cleanup command line arg
This commit is contained in:
@@ -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,17 +26,20 @@ 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.sync_favorites_wrapper(spotify_session, tidal_session, config)
|
||||
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__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user