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

enable Playlists for oauth login flow #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jclds139
Copy link

@jclds139 jclds139 commented Feb 9, 2024

Previously user playlists were only loaded for the old cookie authentication. All that needed to be changed was one conditional.

Several places use the `backend.auth` flag to check if we're logged in
or not. Since the API responds simlarly whether using the OAuth login or
the old cookie login, this unifies those checks back under the
`backend.auth` flag.

To simplify setting it the flag, and since `_ytmusicapi_oauth_json` was
only used for one function, I replaced it with direct references to the
original `config['ytmusic']['oauth_json']`.

Finally, checking before reading from `config` avoids crashes when only
one or the other of `auth_json` or `oauth_json` is present in the config
file
self._ytmusicapi_auth_json = config["ytmusic"]["auth_json"]
if "oauth_json" in config["ytmusic"]:
self.api = YTMusic(auth=config["ytmusic"]["oauth_json"])
self.auth = True
Copy link

@cprn cprn Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I was proposing my changes to use the newer authorisation method, I didn't want to overwrite user files, so I added a separate oauth_json section to the config and left auth_json intact. Later on it made me misread self.auth variable as "authorising through browser", I think, so I added a separate self.oauth for "authorising through OAuth API". Nowadays, I think the original intention for self.auth was to have a boolean equal to True whenever the app is authorised, regardless of how it was authorised. If I knew other devs will have to deal with my changes, I'd just overwrite the damn user file. 😆

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

Successfully merging this pull request may close these issues.

2 participants