From 7cfa006170cc8e7a9d85144d00c869608e9041dd Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 May 2021 03:46:00 +0000 Subject: [PATCH 1/4] Restyled by autopep8 --- examples/player.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/player.py b/examples/player.py index 4f3d3d0..7821be4 100644 --- a/examples/player.py +++ b/examples/player.py @@ -62,7 +62,7 @@ def client(): "q": cmd[2:], "type": "track" }, - headers={"Authorization": "Bearer %s" % token}) + headers={"Authorization": "Bearer %s" % token}) i = 1 tracks = resp.json()["tracks"]["items"] for track in tracks: From 4f11f9bf403150b232802b0a2a13c66018be5929 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 May 2021 03:46:05 +0000 Subject: [PATCH 2/4] Restyled by black --- examples/player.py | 61 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/examples/player.py b/examples/player.py index 7821be4..e0fbcc9 100644 --- a/examples/player.py +++ b/examples/player.py @@ -31,14 +31,18 @@ def client(): return if (args[0] == "p" or args[0] == "play") and len(args) == 2: track_uri_search = re.search( - r"^spotify:track:(?P[0-9a-zA-Z]{22})$", args[1]) + r"^spotify:track:(?P[0-9a-zA-Z]{22})$", args[1] + ) track_url_search = re.search( r"^(https?://)?open.spotify.com/track/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$", - args[1]) + args[1], + ) if track_uri_search is not None or track_url_search is not None: - track_id_str = (track_uri_search - if track_uri_search is not None else - track_url_search).group("TrackID") + track_id_str = ( + track_uri_search + if track_uri_search is not None + else track_url_search + ).group("TrackID") play(track_id_str) wait() if args[0] == "q" or args[0] == "quality": @@ -56,18 +60,22 @@ def client(): wait() if (args[0] == "s" or args[0] == "search") and len(args) >= 2: token = session.tokens().get("user-read-email") - resp = requests.get("https://api.spotify.com/v1/search", { - "limit": "5", - "offset": "0", - "q": cmd[2:], - "type": "track" - }, - headers={"Authorization": "Bearer %s" % token}) + resp = requests.get( + "https://api.spotify.com/v1/search", + {"limit": "5", "offset": "0", "q": cmd[2:], "type": "track"}, + headers={"Authorization": "Bearer %s" % token}, + ) i = 1 tracks = resp.json()["tracks"]["items"] for track in tracks: - print("%d, %s | %s" % (i, track["name"], ",".join( - [artist["name"] for artist in track["artists"]]))) + print( + "%d, %s | %s" + % ( + i, + track["name"], + ",".join([artist["name"] for artist in track["artists"]]), + ) + ) i += 1 position = -1 while True: @@ -105,11 +113,14 @@ def login(): def play(track_id_str: str): track_id = TrackId.from_base62(track_id_str) stream = session.content_feeder().load( - track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None) - ffplay = subprocess.Popen(["ffplay", "-"], - stdin=subprocess.PIPE, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None + ) + ffplay = subprocess.Popen( + ["ffplay", "-"], + stdin=subprocess.PIPE, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) while True: byte = stream.input_stream.stream().read() if byte == -1: @@ -118,11 +129,13 @@ def play(track_id_str: str): def splash(): - print("=================================\n" - "| Librespot-Python Player |\n" - "| |\n" - "| by kokarare1212 |\n" - "=================================\n\n\n") + print( + "=================================\n" + "| Librespot-Python Player |\n" + "| |\n" + "| by kokarare1212 |\n" + "=================================\n\n\n" + ) def main(): From fbad354052e74328f19e0cf8a5c6793221e63921 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 May 2021 03:46:07 +0000 Subject: [PATCH 3/4] Restyled by isort --- examples/player.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/player.py b/examples/player.py index e0fbcc9..2e0f4e1 100644 --- a/examples/player.py +++ b/examples/player.py @@ -1,13 +1,15 @@ +import os +import platform +import re +import subprocess +import time + +import requests + from librespot.audio.decoders import AudioQuality from librespot.core import Session from librespot.metadata import TrackId from librespot.player.codecs import VorbisOnlyAudioQuality -import os -import platform -import re -import requests -import subprocess -import time quality: AudioQuality = AudioQuality.VERY_HIGH session: Session = None From b20b09938b0e2c229df2bbf2b3d9dc5b0e2a8dc5 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 21 May 2021 03:46:15 +0000 Subject: [PATCH 4/4] Restyled by yapf --- examples/player.py | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/examples/player.py b/examples/player.py index 2e0f4e1..fb48690 100644 --- a/examples/player.py +++ b/examples/player.py @@ -33,18 +33,15 @@ def client(): return if (args[0] == "p" or args[0] == "play") and len(args) == 2: track_uri_search = re.search( - r"^spotify:track:(?P[0-9a-zA-Z]{22})$", args[1] - ) + r"^spotify:track:(?P[0-9a-zA-Z]{22})$", args[1]) track_url_search = re.search( r"^(https?://)?open.spotify.com/track/(?P[0-9a-zA-Z]{22})(\?si=.+?)?$", args[1], ) if track_uri_search is not None or track_url_search is not None: - track_id_str = ( - track_uri_search - if track_uri_search is not None - else track_url_search - ).group("TrackID") + track_id_str = (track_uri_search + if track_uri_search is not None else + track_url_search).group("TrackID") play(track_id_str) wait() if args[0] == "q" or args[0] == "quality": @@ -64,20 +61,22 @@ def client(): token = session.tokens().get("user-read-email") resp = requests.get( "https://api.spotify.com/v1/search", - {"limit": "5", "offset": "0", "q": cmd[2:], "type": "track"}, + { + "limit": "5", + "offset": "0", + "q": cmd[2:], + "type": "track" + }, headers={"Authorization": "Bearer %s" % token}, ) i = 1 tracks = resp.json()["tracks"]["items"] for track in tracks: - print( - "%d, %s | %s" - % ( - i, - track["name"], - ",".join([artist["name"] for artist in track["artists"]]), - ) - ) + print("%d, %s | %s" % ( + i, + track["name"], + ",".join([artist["name"] for artist in track["artists"]]), + )) i += 1 position = -1 while True: @@ -115,8 +114,7 @@ def login(): def play(track_id_str: str): track_id = TrackId.from_base62(track_id_str) stream = session.content_feeder().load( - track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None - ) + track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None) ffplay = subprocess.Popen( ["ffplay", "-"], stdin=subprocess.PIPE, @@ -131,13 +129,11 @@ def play(track_id_str: str): def splash(): - print( - "=================================\n" - "| Librespot-Python Player |\n" - "| |\n" - "| by kokarare1212 |\n" - "=================================\n\n\n" - ) + print("=================================\n" + "| Librespot-Python Player |\n" + "| |\n" + "| by kokarare1212 |\n" + "=================================\n\n\n") def main():