From 08caeb19ed6abcfa58448f0197c9c537c2a1fb31 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 May 2021 22:07:58 +0000 Subject: [PATCH 1/4] Restyled by black --- librespot/metadata/__init__.py | 45 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/librespot/metadata/__init__.py b/librespot/metadata/__init__.py index 21ca2c6..dcf7d90 100644 --- a/librespot/metadata/__init__.py +++ b/librespot/metadata/__init__.py @@ -47,9 +47,11 @@ class PlayableId: @staticmethod def is_supported(uri: str): - return not uri.startswith("spotify:local:") and \ - not uri == "spotify:delimiter" and \ - not uri == "spotify:meta:delimiter" + return ( + not uri.startswith("spotify:local:") + and not uri == "spotify:delimiter" + and not uri == "spotify:meta:delimiter" + ) @staticmethod def should_play(track: ContextTrack): @@ -94,8 +96,7 @@ class AlbumId(SpotifyId): matcher = AlbumId._PATTERN.search(uri) if matcher is not None: album_id = matcher.group(1) - return AlbumId( - Utils.bytes_to_hex(AlbumId._BASE62.decode(album_id, 16))) + return AlbumId(Utils.bytes_to_hex(AlbumId._BASE62.decode(album_id, 16))) raise TypeError("Not a Spotify album ID: {}.f".format(uri)) @staticmethod @@ -108,7 +109,8 @@ class AlbumId(SpotifyId): def to_mercury_uri(self) -> str: return "spotify:album:{}".format( - AlbumId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) + AlbumId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) + ) def hex_id(self) -> str: return self._hexId @@ -127,14 +129,12 @@ class ArtistId(SpotifyId): matcher = ArtistId._PATTERN.search(uri) if matcher is not None: artist_id = matcher.group(1) - return ArtistId( - Utils.bytes_to_hex(ArtistId._BASE62.decode(artist_id, 16))) + return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(artist_id, 16))) raise TypeError("Not a Spotify artist ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> ArtistId: - return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, - 16))) + return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> ArtistId: @@ -145,7 +145,8 @@ class ArtistId(SpotifyId): def to_spotify_uri(self) -> str: return "spotify:artist:{}".format( - ArtistId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) + ArtistId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) + ) def hex_id(self) -> str: return self._hexId @@ -164,14 +165,13 @@ class EpisodeId(SpotifyId, PlayableId): if matcher is not None: episode_id = matcher.group(1) return EpisodeId( - Utils.Utils.bytes_to_hex( - PlayableId.BASE62.decode(episode_id, 16))) + Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(episode_id, 16)) + ) TypeError("Not a Spotify episode ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> EpisodeId: - return EpisodeId( - Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) + return EpisodeId(Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> EpisodeId: @@ -182,7 +182,8 @@ class EpisodeId(SpotifyId, PlayableId): def to_spotify_uri(self) -> str: return "Spotify:episode:{}".format( - PlayableId.BASE62.encode(Utils.Utils.hex_to_bytes(self._hexId))) + PlayableId.BASE62.encode(Utils.Utils.hex_to_bytes(self._hexId)) + ) def hex_id(self) -> str: return self._hexId @@ -204,8 +205,7 @@ class ShowId(SpotifyId): matcher = ShowId._PATTERN.search(uri) if matcher is not None: show_id = matcher.group(1) - return ShowId( - Utils.bytes_to_hex(ShowId._BASE62.decode(show_id, 16))) + return ShowId(Utils.bytes_to_hex(ShowId._BASE62.decode(show_id, 16))) raise TypeError("Not a Spotify show ID: {}".format(uri)) @staticmethod @@ -221,7 +221,8 @@ class ShowId(SpotifyId): def to_spotify_uri(self) -> str: return "spotify:show:{}".format( - ShowId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) + ShowId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) + ) def hex_id(self) -> str: return self._hexId @@ -239,14 +240,12 @@ class TrackId(PlayableId, SpotifyId): search = TrackId.PATTERN.search(uri) if search is not None: track_id = search.group(1) - return TrackId( - Utils.bytes_to_hex(PlayableId.BASE62.decode(track_id, 16))) + return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(track_id, 16))) raise RuntimeError("Not a Spotify track ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> TrackId: - return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, - 16))) + return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> TrackId: From 18532c98dc5756279f642306277da5a197640ad6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 May 2021 22:08:00 +0000 Subject: [PATCH 2/4] Restyled by isort --- librespot/metadata/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/librespot/metadata/__init__.py b/librespot/metadata/__init__.py index dcf7d90..9c31da4 100644 --- a/librespot/metadata/__init__.py +++ b/librespot/metadata/__init__.py @@ -1,9 +1,10 @@ from __future__ import annotations -from librespot.common import Base62 -from librespot.common import Utils -from librespot.proto.ContextTrack import ContextTrack + import re +from librespot.common import Base62, Utils +from librespot.proto.ContextTrack import ContextTrack + class SpotifyId: STATIC_FROM_URI = "fromUri" From 9a22d5bc8444e10559f318d54974bfe3414735c7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 May 2021 22:08:04 +0000 Subject: [PATCH 3/4] Restyled by reorder-python-imports --- librespot/metadata/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/librespot/metadata/__init__.py b/librespot/metadata/__init__.py index 9c31da4..53dcf1e 100644 --- a/librespot/metadata/__init__.py +++ b/librespot/metadata/__init__.py @@ -2,7 +2,8 @@ from __future__ import annotations import re -from librespot.common import Base62, Utils +from librespot.common import Base62 +from librespot.common import Utils from librespot.proto.ContextTrack import ContextTrack From 71060fc2c8f31e0a66b5377339b3c49122b07c46 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 May 2021 22:08:08 +0000 Subject: [PATCH 4/4] Restyled by yapf --- librespot/metadata/__init__.py | 45 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/librespot/metadata/__init__.py b/librespot/metadata/__init__.py index 53dcf1e..46204d2 100644 --- a/librespot/metadata/__init__.py +++ b/librespot/metadata/__init__.py @@ -49,11 +49,9 @@ class PlayableId: @staticmethod def is_supported(uri: str): - return ( - not uri.startswith("spotify:local:") - and not uri == "spotify:delimiter" - and not uri == "spotify:meta:delimiter" - ) + return (not uri.startswith("spotify:local:") + and not uri == "spotify:delimiter" + and not uri == "spotify:meta:delimiter") @staticmethod def should_play(track: ContextTrack): @@ -98,7 +96,8 @@ class AlbumId(SpotifyId): matcher = AlbumId._PATTERN.search(uri) if matcher is not None: album_id = matcher.group(1) - return AlbumId(Utils.bytes_to_hex(AlbumId._BASE62.decode(album_id, 16))) + return AlbumId( + Utils.bytes_to_hex(AlbumId._BASE62.decode(album_id, 16))) raise TypeError("Not a Spotify album ID: {}.f".format(uri)) @staticmethod @@ -111,8 +110,7 @@ class AlbumId(SpotifyId): def to_mercury_uri(self) -> str: return "spotify:album:{}".format( - AlbumId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) - ) + AlbumId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) def hex_id(self) -> str: return self._hexId @@ -131,12 +129,14 @@ class ArtistId(SpotifyId): matcher = ArtistId._PATTERN.search(uri) if matcher is not None: artist_id = matcher.group(1) - return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(artist_id, 16))) + return ArtistId( + Utils.bytes_to_hex(ArtistId._BASE62.decode(artist_id, 16))) raise TypeError("Not a Spotify artist ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> ArtistId: - return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, 16))) + return ArtistId(Utils.bytes_to_hex(ArtistId._BASE62.decode(base62, + 16))) @staticmethod def from_hex(hex_str: str) -> ArtistId: @@ -147,8 +147,7 @@ class ArtistId(SpotifyId): def to_spotify_uri(self) -> str: return "spotify:artist:{}".format( - ArtistId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) - ) + ArtistId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) def hex_id(self) -> str: return self._hexId @@ -167,13 +166,14 @@ class EpisodeId(SpotifyId, PlayableId): if matcher is not None: episode_id = matcher.group(1) return EpisodeId( - Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(episode_id, 16)) - ) + Utils.Utils.bytes_to_hex( + PlayableId.BASE62.decode(episode_id, 16))) TypeError("Not a Spotify episode ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> EpisodeId: - return EpisodeId(Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) + return EpisodeId( + Utils.Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) @staticmethod def from_hex(hex_str: str) -> EpisodeId: @@ -184,8 +184,7 @@ class EpisodeId(SpotifyId, PlayableId): def to_spotify_uri(self) -> str: return "Spotify:episode:{}".format( - PlayableId.BASE62.encode(Utils.Utils.hex_to_bytes(self._hexId)) - ) + PlayableId.BASE62.encode(Utils.Utils.hex_to_bytes(self._hexId))) def hex_id(self) -> str: return self._hexId @@ -207,7 +206,8 @@ class ShowId(SpotifyId): matcher = ShowId._PATTERN.search(uri) if matcher is not None: show_id = matcher.group(1) - return ShowId(Utils.bytes_to_hex(ShowId._BASE62.decode(show_id, 16))) + return ShowId( + Utils.bytes_to_hex(ShowId._BASE62.decode(show_id, 16))) raise TypeError("Not a Spotify show ID: {}".format(uri)) @staticmethod @@ -223,8 +223,7 @@ class ShowId(SpotifyId): def to_spotify_uri(self) -> str: return "spotify:show:{}".format( - ShowId._BASE62.encode(Utils.hex_to_bytes(self._hexId)) - ) + ShowId._BASE62.encode(Utils.hex_to_bytes(self._hexId))) def hex_id(self) -> str: return self._hexId @@ -242,12 +241,14 @@ class TrackId(PlayableId, SpotifyId): search = TrackId.PATTERN.search(uri) if search is not None: track_id = search.group(1) - return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(track_id, 16))) + return TrackId( + Utils.bytes_to_hex(PlayableId.BASE62.decode(track_id, 16))) raise RuntimeError("Not a Spotify track ID: {}".format(uri)) @staticmethod def from_base62(base62: str) -> TrackId: - return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, 16))) + return TrackId(Utils.bytes_to_hex(PlayableId.BASE62.decode(base62, + 16))) @staticmethod def from_hex(hex_str: str) -> TrackId: