From 6817cd8e07c8492edd5ba6e51fa66848f1979b2a Mon Sep 17 00:00:00 2001 From: "Zander M." Date: Mon, 11 Mar 2024 13:23:42 -0400 Subject: [PATCH 1/4] Fix build_track failure with Lavalink v4 decodetrack format. --- .gitignore | 1 + pomice/pool.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8f71d00..c3df3dc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ build/ Pipfile.lock .mypy_cache/ .vscode/ +.idea/ .venv/ *.code-workspace *.ini diff --git a/pomice/pool.py b/pomice/pool.py index 64564af..1446444 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -545,11 +545,19 @@ class Node: path="decodetrack", query=f"encodedTrack={quote(identifier)}", ) + + if self._version.major >= 4: + track_info = data["info"] + track_type = data["info"]["sourceName"] + else: + track_info = data + track_type = data["sourceName"] + return Track( track_id=identifier, ctx=ctx, - info=data, - track_type=TrackType(data["sourceName"]), + info=track_info, + track_type=TrackType(track_type), ) async def get_tracks( From bb12e335840518dff2d8a7a388a069e1740942b6 Mon Sep 17 00:00:00 2001 From: "Zander M." Date: Mon, 11 Mar 2024 13:24:54 -0400 Subject: [PATCH 2/4] Python Black Format --- pomice/__init__.py | 1 + pomice/applemusic/__init__.py | 1 + pomice/applemusic/objects.py | 1 + pomice/spotify/__init__.py | 1 + 4 files changed, 4 insertions(+) diff --git a/pomice/__init__.py b/pomice/__init__.py index 84b4718..a464044 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -7,6 +7,7 @@ Copyright (c) 2023, cloudwithax Licensed under GPL-3.0 """ + import discord if not discord.version_info.major >= 2: diff --git a/pomice/applemusic/__init__.py b/pomice/applemusic/__init__.py index d1ceb72..a2349fa 100644 --- a/pomice/applemusic/__init__.py +++ b/pomice/applemusic/__init__.py @@ -1,4 +1,5 @@ """Apple Music module for Pomice, made possible by cloudwithax 2023""" + from .client import * from .exceptions import * from .objects import * diff --git a/pomice/applemusic/objects.py b/pomice/applemusic/objects.py index 75d173d..548da38 100644 --- a/pomice/applemusic/objects.py +++ b/pomice/applemusic/objects.py @@ -1,4 +1,5 @@ """Module for managing Apple Music objects""" + from typing import List __all__ = ( diff --git a/pomice/spotify/__init__.py b/pomice/spotify/__init__.py index e28be28..71ca60a 100644 --- a/pomice/spotify/__init__.py +++ b/pomice/spotify/__init__.py @@ -1,4 +1,5 @@ """Spotify module for Pomice, made possible by cloudwithax 2023""" + from .client import Client from .exceptions import * from .objects import * From 83d5add134041dbacbfc90e48e4fb231ac590cee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:29:46 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pomice/__init__.py | 1 - pomice/applemusic/__init__.py | 1 - pomice/applemusic/objects.py | 1 - pomice/spotify/__init__.py | 1 - 4 files changed, 4 deletions(-) diff --git a/pomice/__init__.py b/pomice/__init__.py index a464044..84b4718 100644 --- a/pomice/__init__.py +++ b/pomice/__init__.py @@ -7,7 +7,6 @@ Copyright (c) 2023, cloudwithax Licensed under GPL-3.0 """ - import discord if not discord.version_info.major >= 2: diff --git a/pomice/applemusic/__init__.py b/pomice/applemusic/__init__.py index a2349fa..d1ceb72 100644 --- a/pomice/applemusic/__init__.py +++ b/pomice/applemusic/__init__.py @@ -1,5 +1,4 @@ """Apple Music module for Pomice, made possible by cloudwithax 2023""" - from .client import * from .exceptions import * from .objects import * diff --git a/pomice/applemusic/objects.py b/pomice/applemusic/objects.py index 548da38..75d173d 100644 --- a/pomice/applemusic/objects.py +++ b/pomice/applemusic/objects.py @@ -1,5 +1,4 @@ """Module for managing Apple Music objects""" - from typing import List __all__ = ( diff --git a/pomice/spotify/__init__.py b/pomice/spotify/__init__.py index 71ca60a..e28be28 100644 --- a/pomice/spotify/__init__.py +++ b/pomice/spotify/__init__.py @@ -1,5 +1,4 @@ """Spotify module for Pomice, made possible by cloudwithax 2023""" - from .client import Client from .exceptions import * from .objects import * From 347a6e0b964223fe32d537c1dc7ea474f28651ca Mon Sep 17 00:00:00 2001 From: "Zander M." Date: Mon, 11 Mar 2024 13:50:07 -0400 Subject: [PATCH 4/4] Refactor sourceName to use track_info object. --- pomice/pool.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pomice/pool.py b/pomice/pool.py index 1446444..74f479d 100644 --- a/pomice/pool.py +++ b/pomice/pool.py @@ -546,18 +546,13 @@ class Node: query=f"encodedTrack={quote(identifier)}", ) - if self._version.major >= 4: - track_info = data["info"] - track_type = data["info"]["sourceName"] - else: - track_info = data - track_type = data["sourceName"] + track_info = data["info"] if self._version.major >= 4 else data return Track( track_id=identifier, ctx=ctx, info=track_info, - track_type=TrackType(track_type), + track_type=TrackType(track_info["sourceName"]), ) async def get_tracks(