Add librespot.audio.decoders

This commit is contained in:
kokarare1212
2021-05-20 07:03:32 +09:00
parent 60adbd8beb
commit 8d86accf48
7 changed files with 16 additions and 13 deletions

View File

@@ -36,18 +36,20 @@ aceess_token = session.tokens().get("playlist-read")
``` ```
### Get Music Stream ### Get Music Stream
\*Currently, music streaming is supported, but it may cause unintended behavior. \*Currently, music streaming is supported, but it may cause unintended behavior.
```python ```python
from librespot.core import Session from librespot.core import Session
from librespot.metadata import TrackId from librespot.metadata import TrackId
from librespot.player.codecs import AudioQuality, VorbisOnlyAudioQuality from librespot.player.codecs import VorbisOnlyAudioQuality
from librespot.audio.decoders import AudioQuality
session = Session.Builder()
session = Session.Builder() \ .user_pass("Username", "Password")
.user_pass("Username", "Password") \
.create() .create()
track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx") track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx")
stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.AudioQuality.VERY_HIGH), False, None) stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.AudioQuality.VERY_HIGH), False,
None)
# stream.input_stream.stream().read() to get one byte of the music stream. # stream.input_stream.stream().read() to get one byte of the music stream.
# ex: 1 (If there is no more voice data, -1 is received as the result.) # ex: 1 (If there is no more voice data, -1 is received as the result.)
``` ```

View File

@@ -69,15 +69,16 @@ aceess_token = session.tokens().get("playlist-read")
```python ```python
from librespot.core import Session from librespot.core import Session
from librespot.metadata import TrackId from librespot.metadata import TrackId
from librespot.player.codecs import AudioQuality, VorbisOnlyAudioQuality from librespot.player.codecs import VorbisOnlyAudioQuality
from librespot.audio.decoders import AudioQuality
session = Session.Builder()
session = Session.Builder() \ .user_pass("Username", "Password")
.user_pass("Username", "Password") \
.create() .create()
track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx") track_id = TrackId.from_uri("spotify:track:xxxxxxxxxxxxxxxxxxxxxx")
stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.AudioQuality.VERY_HIGH), False, None) stream = session.content_feeder().load(track_id, VorbisOnlyAudioQuality(AudioQuality.AudioQuality.VERY_HIGH), False,
None)
# stream.input_stream.stream().read() to get one byte of the music stream. # stream.input_stream.stream().read() to get one byte of the music stream.
# ex: 1 (If there is no more voice data, -1 is received as the result.) # ex: 1 (If there is no more voice data, -1 is received as the result.)
``` ```

View File

@@ -0,0 +1 @@
from librespot.audio.decoders.AudioQuality import AudioQuality

View File

@@ -1,5 +1,5 @@
from __future__ import annotations from __future__ import annotations
from librespot.player.codecs import AudioQuality from librespot.audio.decoders import AudioQuality
class PlayerConfiguration: class PlayerConfiguration:

View File

@@ -5,7 +5,7 @@ import typing
from librespot.audio.format.AudioQualityPicker import AudioQualityPicker from librespot.audio.format.AudioQualityPicker import AudioQualityPicker
from librespot.audio.format.SuperAudioFormat import SuperAudioFormat from librespot.audio.format.SuperAudioFormat import SuperAudioFormat
from librespot.player.codecs.AudioQuality import AudioQuality from librespot.audio.decoders.AudioQuality import AudioQuality
from librespot.proto import Metadata from librespot.proto import Metadata

View File

@@ -1,2 +1 @@
from librespot.player.codecs.AudioQuality import AudioFile
from librespot.player.codecs.VorbisOnlyAudioQuality import VorbisOnlyAudioQuality from librespot.player.codecs.VorbisOnlyAudioQuality import VorbisOnlyAudioQuality