diff --git a/__pycache__/musictail_mcp.cpython-311.pyc b/__pycache__/musictail_mcp.cpython-311.pyc new file mode 100644 index 0000000..36bf912 Binary files /dev/null and b/__pycache__/musictail_mcp.cpython-311.pyc differ diff --git a/musictail_mcp.py b/musictail_mcp.py index cf92807..e183663 100644 --- a/musictail_mcp.py +++ b/musictail_mcp.py @@ -32,10 +32,10 @@ def get_spotify_client() -> spotipy.Spotify: auth_manager = SpotifyOAuth( client_id=os.environ.get("SPOTIFY_CLIENT_ID"), client_secret=os.environ.get("SPOTIFY_CLIENT_SECRET"), - redirect_uri="http://127.0.0.1:8889/callback", + redirect_uri="http://127.0.0.1:8888/callback", scope=SCOPES, cache_path=cache_path, - open_browser=True + open_browser=False ) return spotipy.Spotify(auth_manager=auth_manager) @@ -301,11 +301,32 @@ if __name__ == "__main__": import sys if "--auth" in sys.argv: print("šŸŽµ MusicTail — First-time authorization") - print("A browser window will open for Spotify login...") - sp = get_spotify_client() - user = sp.current_user() - print(f"āœ… Authorized as: {user['display_name']} ({user['id']})") - print(f"Token cached at: ~/.musictail_cache") - print("MusicTail is ready! 🦊") + print() + cache_path = os.path.expanduser("~/.musictail_cache") + auth_manager = SpotifyOAuth( + client_id=os.environ.get("SPOTIFY_CLIENT_ID"), + client_secret=os.environ.get("SPOTIFY_CLIENT_SECRET"), + redirect_uri="http://127.0.0.1:8888/callback", + scope=SCOPES, + cache_path=cache_path, + open_browser=False + ) + # Get the auth URL + auth_url = auth_manager.get_authorize_url() + print(f"Open this URL in your browser:\n{auth_url}\n") + print("After authorizing, you'll be redirected to a URL.") + print("Paste the FULL redirect URL here (it will start with http://127.0.0.1:8888/callback?code=...):") + response_url = input("> ").strip() + code = auth_manager.parse_response_code(response_url) + token_info = auth_manager.get_access_token(code) + + if token_info: + sp = spotipy.Spotify(auth_manager=auth_manager) + user = sp.current_user() + print(f"\nāœ… Authorized as: {user['display_name']} ({user['id']})") + print(f"Token cached at: {cache_path}") + print("MusicTail is ready! 🦊") + else: + print("āŒ Authorization failed. Check your credentials.") else: mcp.run() \ No newline at end of file