Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't log in yt music #155

Open
down2hell opened this issue Dec 31, 2024 · 1 comment
Open

Can't log in yt music #155

down2hell opened this issue Dec 31, 2024 · 1 comment

Comments

@down2hell
Copy link

I'm using the gui. When I click login it says "file not detected, login required" and it does open ytmusicapi.exe, but it doesn't provide a URL like the readme says, instead it just shows "Enter your Google Youtube Data API client ID". I might just be stupid, but I can't figure out what to do here.

@Kav47
Copy link

Kav47 commented Jan 5, 2025

Looks like Youtube Music made some changes and you'll need a Google Cloud Project to get things working with Oauth. You can read about it here. Your best bet is to use browser auth.
I followed this: #125 (comment)

  1. Open a new tab with web developer tools and go to YT Music
  2. Open the "Network" tab and filter for "browse?" If it doesn't show up, refresh the page (Ctrl + Shift + R / CMD + Shift + R), and scroll down or play any song. Screenshot 2025-01-05 at 20 47 30
  3. Git clone the repo with git clone https://github.com/linsomniac/spotify_to_ytmusic and cd spotify_to_ytmusic
  4. Install the required dependencies pip install ytmusicapi and pip install tk
  5. For Windows/ Linux: run the command ytmusicapi browser and paste whatever you copied.
  6. For Mac: run the command pbpaste | ytmusicapi browser
  7. edit the backend.py file: open the spotify2ytmusic/backend.py file in your preferred text editor or nano spotify2ytmusic/backend.py
  8. Just above line 22, if not os.path.exists("oauth.json"): add the following line return YTMusic("browser.json"). Save the file. The "def get_ytmusic() -> YTMusic:" block should look like the following:
def get_ytmusic() -> YTMusic:
    """
    @@@
    """
    return YTMusic("browser.json")
    if not os.path.exists("oauth.json"):
        print("ERROR: No file 'oauth.json' exists in the current directory.")
        print("       Have you logged in to YTMusic?  Run 'ytmusicapi oauth' to login")
        sys.exit(1)

    try:
        return YTMusic("oauth.json")
    except json.decoder.JSONDecodeError as e:
        print(f"ERROR: JSON Decode error while trying start YTMusic: {e}")
        print("       This typically means a problem with a 'oauth.json' file.")
        print("       Have you logged in to YTMusic?  Run 'ytmusicapi oauth' to login")
        sys.exit(1)
  1. Run python3 -m spotify2ytmusic list_playlists to check whether the tool is working. It should display your YouTube Music playlists.
  2. Run python3 -m spotify2ytmusic gui
  3. Now you can "Load liked songs" and "Copy all playlists" from the tabs.

Update:

  • If you are importing a large number of songs, you might get a '401: Unauthorized' error after some time. You'll need to update your browser authentication (refer to steps 2 and 5/6). Once the browser.json is updated, run step 10 again.
  • I also had some problems with my huge library. To fix it, I had to delete songs that were updated in that 'playlists.json' file. Whenever I got that '401 Unauthorized' error, I searched the song in the JSON file. Then, I deleted all the songs block listed below it and try loading everything again.

Ref:
https://ytmusicapi.readthedocs.io/en/stable/setup/browser.html
sigma67/ytmusicapi#679
sigma67/ytmusicapi#682
Thanks to @ohadklein11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants