Merge remote-tracking branch 'origin/main'
# Conflicts: # docs/index.md
This commit is contained in:
21
SECURITY.md
Normal file
21
SECURITY.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Use this section to tell people about which versions of your project are
|
||||||
|
currently being supported with security updates.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 5.1.x | :white_check_mark: |
|
||||||
|
| 5.0.x | :x: |
|
||||||
|
| 4.0.x | :white_check_mark: |
|
||||||
|
| < 4.0 | :x: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
Use this section to tell people how to report a vulnerability.
|
||||||
|
|
||||||
|
Tell them where to go, how often they can expect to get an update on a
|
||||||
|
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||||
|
declined, etc.
|
||||||
@@ -2,10 +2,15 @@
|
|||||||

|

|
||||||

|

|
||||||
[](https://deepsource.io/gh/kokarare1212/librespot-python/?ref=repository-badge)
|
[](https://deepsource.io/gh/kokarare1212/librespot-python/?ref=repository-badge)
|
||||||
|
|
||||||
# Get Started
|
# Get Started
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
|
* [Get Started](index.md)
|
||||||
* [Supported Futures](supported.md)
|
* [Supported Futures](supported.md)
|
||||||
* [API Reference](api.md)
|
* [API Reference](api.md)
|
||||||
|
|
||||||
## What's librespot-python?
|
## What's librespot-python?
|
||||||
|
|
||||||
librespot-python is a python port of Spotify's open source client library [librespot](https://github.com/librespot-org/librespot).
|
librespot-python is a python port of Spotify's open source client library [librespot](https://github.com/librespot-org/librespot).
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
## Supported Futures
|
## Supported Futures
|
||||||
|
|
||||||
| Futures | Supported |
|
| Futures | Supported |
|
||||||
|
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
|
||||||
| Get Metadata | 〇 |
|
| Get Metadata | 〇 |
|
||||||
|
|
||||||
| Play Music | △*1 |
|
| Play Music | △*1 |
|
||||||
|
|
||||||
| Spotify Connect | ×*2 |
|
| Spotify Connect | ×*2 |
|
||||||
|
|
||||||
*1 It is currently possible to retrieve the music stream, but it requires separate software for decoding.
|
*1 It is currently possible to retrieve the music stream, but it requires separate software for decoding.
|
||||||
|
|
||||||
*2 This feature will be added in the future.
|
*2 This feature will be added in the future.
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from librespot.common import Utils
|
|
||||||
from librespot.core import Session
|
|
||||||
from librespot.crypto import DiffieHellman
|
|
||||||
from librespot.standard import Closeable, Runnable
|
|
||||||
from librespot.proto import Connect
|
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
from librespot.common import Utils
|
||||||
|
from librespot.core import Session
|
||||||
|
from librespot.crypto import DiffieHellman
|
||||||
|
from librespot.proto import Connect
|
||||||
|
from librespot.standard import Closeable
|
||||||
|
from librespot.standard import Runnable
|
||||||
|
|
||||||
|
|
||||||
class ZeroconfServer(Closeable):
|
class ZeroconfServer(Closeable):
|
||||||
__MAX_PORT = 65536
|
__MAX_PORT = 65536
|
||||||
@@ -16,7 +19,8 @@ class ZeroconfServer(Closeable):
|
|||||||
__keys: DiffieHellman
|
__keys: DiffieHellman
|
||||||
__inner: ZeroconfServer.Inner
|
__inner: ZeroconfServer.Inner
|
||||||
|
|
||||||
def __init__(self, inner: ZeroconfServer.Inner, listen_port: int, listen_all: bool):
|
def __init__(self, inner: ZeroconfServer.Inner, listen_port: int,
|
||||||
|
listen_all: bool):
|
||||||
self.__inner = inner
|
self.__inner = inner
|
||||||
self.__keys = DiffieHellman()
|
self.__keys = DiffieHellman()
|
||||||
|
|
||||||
@@ -39,7 +43,17 @@ class ZeroconfServer(Closeable):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def create(self) -> ZeroconfServer:
|
def create(self) -> ZeroconfServer:
|
||||||
return ZeroconfServer(ZeroconfServer.Inner(self.device_type, self.device_name, self.preferred_locale, self.conf, self.device_id), self.__listenPort, self.__listenAll)
|
return ZeroconfServer(
|
||||||
|
ZeroconfServer.Inner(
|
||||||
|
self.device_type,
|
||||||
|
self.device_name,
|
||||||
|
self.preferred_locale,
|
||||||
|
self.conf,
|
||||||
|
self.device_id,
|
||||||
|
),
|
||||||
|
self.__listenPort,
|
||||||
|
self.__listenAll,
|
||||||
|
)
|
||||||
|
|
||||||
class Inner:
|
class Inner:
|
||||||
device_type: Connect.DeviceType = None
|
device_type: Connect.DeviceType = None
|
||||||
@@ -48,22 +62,25 @@ class ZeroconfServer(Closeable):
|
|||||||
preferred_locale: str = None
|
preferred_locale: str = None
|
||||||
conf = None
|
conf = None
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
|
self,
|
||||||
device_type: Connect.DeviceType,
|
device_type: Connect.DeviceType,
|
||||||
device_name: str,
|
device_name: str,
|
||||||
preferred_locale: str,
|
preferred_locale: str,
|
||||||
conf: Session.Configuration,
|
conf: Session.Configuration,
|
||||||
device_id: str = None):
|
device_id: str = None,
|
||||||
|
):
|
||||||
self.preferred_locale = preferred_locale
|
self.preferred_locale = preferred_locale
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.device_type = device_type
|
self.device_type = device_type
|
||||||
self.device_name = device_name
|
self.device_name = device_name
|
||||||
self.device_id = device_id if device_id is not None else Utils.random_hex_string(
|
self.device_id = (device_id if device_id is not None else
|
||||||
40)
|
Utils.random_hex_string(40))
|
||||||
|
|
||||||
class HttpRunner(Runnable, Closeable):
|
class HttpRunner(Runnable, Closeable):
|
||||||
__sock: socket
|
__sock: socket
|
||||||
__executorService: concurrent.futures.ThreadPoolExecutor = concurrent.futures.ThreadPoolExecutor()
|
__executorService: concurrent.futures.ThreadPoolExecutor = (
|
||||||
|
concurrent.futures.ThreadPoolExecutor())
|
||||||
__shouldStop: bool = False
|
__shouldStop: bool = False
|
||||||
|
|
||||||
def __init__(self, port: int):
|
def __init__(self, port: int):
|
||||||
@@ -86,4 +103,3 @@ class ZeroconfServer(Closeable):
|
|||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
super().close()
|
super().close()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from librespot.common import Base62
|
from librespot.common import Base62
|
||||||
from librespot.common import Utils
|
from librespot.common import Utils
|
||||||
from librespot.proto.ContextTrack import ContextTrack
|
from librespot.proto.ContextTrack import ContextTrack
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class SpotifyId:
|
class SpotifyId:
|
||||||
@@ -47,9 +49,9 @@ class PlayableId:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_supported(uri: str):
|
def is_supported(uri: str):
|
||||||
return not uri.startswith("spotify:local:") and \
|
return (not uri.startswith("spotify:local:")
|
||||||
not uri == "spotify:delimiter" and \
|
and not uri == "spotify:delimiter"
|
||||||
not uri == "spotify:meta:delimiter"
|
and not uri == "spotify:meta:delimiter")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def should_play(track: ContextTrack):
|
def should_play(track: ContextTrack):
|
||||||
@@ -260,5 +262,3 @@ class TrackId(PlayableId, SpotifyId):
|
|||||||
|
|
||||||
def get_gid(self) -> bytes:
|
def get_gid(self) -> bytes:
|
||||||
return Utils.hex_to_bytes(self._hexId)
|
return Utils.hex_to_bytes(self._hexId)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user