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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions mopidy_ytmusic/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(self, config, audio):
self.audio = audio
self.uri_schemes = ["ytmusic"]
self.auth = False
self.oauth = False

self._auto_playlist_refresh_rate = (
config["ytmusic"]["auto_playlist_refresh"] * 60
Expand All @@ -58,18 +57,12 @@ def __init__(self, config, audio):
self.stream_preference = config["ytmusic"]["stream_preference"]
self.verify_track_url = config["ytmusic"]["verify_track_url"]

if config["ytmusic"]["auth_json"]:
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. 😆

elif "auth_json" in config["ytmusic"]:
self.api = YTMusic(config["ytmusic"]["auth_json"])
self.auth = True

if config["ytmusic"]["oauth_json"]:
self._ytmusicapi_oauth_json = config["ytmusic"]["oauth_json"]
self.oauth = True

if self.auth and not self.oauth:
self.api = YTMusic(auth=self._ytmusicapi_auth_json)
elif self.oauth:
self.api = YTMusic(auth=self._ytmusicapi_oauth_json)
else:
self.api = YTMusic()

Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ sections = "FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,TESTS,LOCALFOLDER"

[tool.poetry]
name = "Mopidy-YTMusic"
version = "0.3.8"
version = "0.3.9"
description = "Mopidy extension for playling music/managing playlists in Youtube Music"
authors = ["Ozymandias (Tomas Ravinskas) <[email protected]>"]
license = "Apache-2.0"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.9"
Mopidy = "^3"
pytube = "^12.1.0"
ytmusicapi = ">=0.22.0, <0.30.0"
pytube = "^15.0.0"
ytmusicapi = ">=1.0"

[tool.poetry.dev-dependencies]
flake8 = "^3.8.4"
Expand Down