Format code with yapf
This commit fixes the style issues introduced in 4635bf8 according to the output
from yapf.
Details: https://deepsource.io/gh/kokarare1212/librespot-python/transform/556eb7b2-7632-467e-b1b4-8e463d91a708/
This commit is contained in:
committed by
GitHub
parent
4635bf8d24
commit
fc57a76aa0
@@ -30,10 +30,15 @@ def client():
|
|||||||
if args[0] == "exit" or args[0] == "quit":
|
if args[0] == "exit" or args[0] == "quit":
|
||||||
return
|
return
|
||||||
if (args[0] == "p" or args[0] == "play") and len(args) == 2:
|
if (args[0] == "p" or args[0] == "play") and len(args) == 2:
|
||||||
track_uri_search = re.search(r"^spotify:track:(?P<TrackID>[0-9a-zA-Z]{22})$", args[1])
|
track_uri_search = re.search(
|
||||||
track_url_search = re.search(r"^(https?://)?open.spotify.com/track/(?P<TrackID>[0-9a-zA-Z]{22})(\?si=.+?)?$", args[1])
|
r"^spotify:track:(?P<TrackID>[0-9a-zA-Z]{22})$", args[1])
|
||||||
|
track_url_search = re.search(
|
||||||
|
r"^(https?://)?open.spotify.com/track/(?P<TrackID>[0-9a-zA-Z]{22})(\?si=.+?)?$",
|
||||||
|
args[1])
|
||||||
if track_uri_search is not None or track_url_search is not None:
|
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)
|
play(track_id_str)
|
||||||
wait()
|
wait()
|
||||||
if args[0] == "q" or args[0] == "quality":
|
if args[0] == "q" or args[0] == "quality":
|
||||||
@@ -51,11 +56,18 @@ def client():
|
|||||||
wait()
|
wait()
|
||||||
if (args[0] == "s" or args[0] == "search") and len(args) <= 2:
|
if (args[0] == "s" or args[0] == "search") and len(args) <= 2:
|
||||||
token = session.tokens().get("user-read-email")
|
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
|
i = 1
|
||||||
tracks = resp.json()["tracks"]["items"]
|
tracks = resp.json()["tracks"]["items"]
|
||||||
for track in tracks:
|
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
|
i += 1
|
||||||
position = -1
|
position = -1
|
||||||
while True:
|
while True:
|
||||||
@@ -92,11 +104,11 @@ def login():
|
|||||||
|
|
||||||
def play(track_id_str: str):
|
def play(track_id_str: str):
|
||||||
track_id = TrackId.from_base62(track_id_str)
|
track_id = TrackId.from_base62(track_id_str)
|
||||||
stream = session.content_feeder().load(track_id,
|
stream = session.content_feeder().load(
|
||||||
VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH),
|
track_id, VorbisOnlyAudioQuality(AudioQuality.VERY_HIGH), False, None)
|
||||||
False,
|
ffplay = subprocess.Popen(["ffplay", "-"],
|
||||||
None)
|
stdin=subprocess.PIPE,
|
||||||
ffplay = subprocess.Popen(["ffplay", "-"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
while True:
|
while True:
|
||||||
byte = stream.input_stream.stream().read()
|
byte = stream.input_stream.stream().read()
|
||||||
@@ -107,8 +119,7 @@ def play(track_id_str: str):
|
|||||||
|
|
||||||
|
|
||||||
def splash():
|
def splash():
|
||||||
print(
|
print("=================================\n"
|
||||||
"=================================\n"
|
|
||||||
"| Librespot-Python Player |\n"
|
"| Librespot-Python Player |\n"
|
||||||
"| |\n"
|
"| |\n"
|
||||||
"| by kokarare1212 |\n"
|
"| by kokarare1212 |\n"
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ class AbsChunkedInputStream(InputStream, HaltListener):
|
|||||||
raise IOError("Stream is closed!")
|
raise IOError("Stream is closed!")
|
||||||
self._pos = where
|
self._pos = where
|
||||||
|
|
||||||
self.check_availability(int(self._pos / (128 * 1024)),
|
self.check_availability(int(self._pos / (128 * 1024)), False, False)
|
||||||
False, False)
|
|
||||||
|
|
||||||
def skip(self, n: int) -> int:
|
def skip(self, n: int) -> int:
|
||||||
if n < 0:
|
if n < 0:
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class CdnFeedHelper:
|
|||||||
|
|
||||||
streamer = session.cdn().stream_file(file, key, url, halt_listener)
|
streamer = session.cdn().stream_file(file, key, url, halt_listener)
|
||||||
input_stream = streamer.stream()
|
input_stream = streamer.stream()
|
||||||
normalization_data = NormalizationData.NormalizationData.read(input_stream)
|
normalization_data = NormalizationData.NormalizationData.read(
|
||||||
|
input_stream)
|
||||||
if input_stream.skip(0xa7) != 0xa7:
|
if input_stream.skip(0xa7) != 0xa7:
|
||||||
raise IOError("Couldn't skip 0xa7 bytes!")
|
raise IOError("Couldn't skip 0xa7 bytes!")
|
||||||
return PlayableContentFeeder.PlayableContentFeeder.LoadedStream(
|
return PlayableContentFeeder.PlayableContentFeeder.LoadedStream(
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ class CdnManager:
|
|||||||
else:
|
else:
|
||||||
self._expiration = -1
|
self._expiration = -1
|
||||||
|
|
||||||
class Streamer(GeneralAudioStream.GeneralAudioStream, GeneralWritableStream.GeneralWritableStream):
|
class Streamer(GeneralAudioStream.GeneralAudioStream,
|
||||||
|
GeneralWritableStream.GeneralWritableStream):
|
||||||
_session: Session = None
|
_session: Session = None
|
||||||
_streamId: StreamId = None
|
_streamId: StreamId = None
|
||||||
_executorService = concurrent.futures.ThreadPoolExecutor()
|
_executorService = concurrent.futures.ThreadPoolExecutor()
|
||||||
|
|||||||
@@ -245,7 +245,8 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
|
|||||||
self._channelManager = ChannelManager(self)
|
self._channelManager = ChannelManager(self)
|
||||||
self._api = ApiClient.ApiClient(self)
|
self._api = ApiClient.ApiClient(self)
|
||||||
self._cdnManager = CdnManager(self)
|
self._cdnManager = CdnManager(self)
|
||||||
self._contentFeeder = PlayableContentFeeder.PlayableContentFeeder(self)
|
self._contentFeeder = PlayableContentFeeder.PlayableContentFeeder(
|
||||||
|
self)
|
||||||
self._cacheManager = CacheManager(self)
|
self._cacheManager = CacheManager(self)
|
||||||
self._dealer = DealerClient(self)
|
self._dealer = DealerClient(self)
|
||||||
self._search = SearchManager.SearchManager(self)
|
self._search = SearchManager.SearchManager(self)
|
||||||
|
|||||||
Reference in New Issue
Block a user