type hint, move
This commit is contained in:
35
src/spotify_to_tidal/__main__.py
Normal file
35
src/spotify_to_tidal/__main__.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import yaml
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from . import sync as _sync
|
||||
from . import auth as _auth
|
||||
|
||||
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')
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.config, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
spotify_session = _auth.open_spotify_session(config['spotify'])
|
||||
tidal_session = _auth.open_tidal_session()
|
||||
if not tidal_session.check_login():
|
||||
sys.exit("Could not connect to Tidal")
|
||||
if args.uri:
|
||||
# if a playlist ID is explicitly provided as a command line argument then use that
|
||||
spotify_playlist = spotify_session.playlist(args.uri)
|
||||
tidal_playlists = _sync.get_tidal_playlists_dict(tidal_session)
|
||||
tidal_playlist = _sync.pick_tidal_playlist_for_spotify_playlist(spotify_playlist, tidal_playlists)
|
||||
_sync.sync_list(spotify_session, tidal_session, [tidal_playlist], config)
|
||||
elif config.get('sync_playlists', None):
|
||||
# if the config contains a sync_playlists list of mappings then use that
|
||||
_sync.sync_list(spotify_session, tidal_session, _sync.get_playlists_from_config(config), config)
|
||||
else:
|
||||
# otherwise just use the user playlists in the Spotify account
|
||||
_sync.sync_list(spotify_session, tidal_session, _sync.get_user_playlist_mappings(spotify_session, tidal_session, config), config)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user