it only works on premium accounts dont read the code or commits i swear
This commit is contained in:
parent
7888e685ec
commit
9e397dc673
11 changed files with 46 additions and 5 deletions
|
@ -4,27 +4,35 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), "deps"))
|
|||
from wsgiref.simple_server import make_server
|
||||
|
||||
from bottle import app, request, HTTPResponse, Bottle
|
||||
import xbmc
|
||||
import xbmcaddon
|
||||
|
||||
from librespot.core import Session
|
||||
from librespot.audio.decoders import AudioQuality, VorbisOnlyAudioQuality
|
||||
from librespot.metadata import TrackId
|
||||
|
||||
from utils import log_msg
|
||||
from utils import ADDON_ID, log_msg
|
||||
|
||||
class LibrespotServer(Bottle):
|
||||
__addon: xbmcaddon.Addon = xbmcaddon.Addon(id=ADDON_ID)
|
||||
|
||||
def __init__(self, session: Session):
|
||||
super(LibrespotServer, self).__init__()
|
||||
self.session: Session = session
|
||||
self.route('/track/<track_id>', callback=self.stream)
|
||||
self.is_premium: bool = self.__addon.getSetting("isPremium")
|
||||
|
||||
# TODO: Make Range header work PLEASE I BEG
|
||||
|
||||
def stream(self, track_id):
|
||||
try:
|
||||
playabletrack_id = TrackId.from_uri(f"spotify:track:{track_id}")
|
||||
|
||||
quality = AudioQuality.NORMAL
|
||||
if self.is_premium:
|
||||
quality = AudioQuality.VERY_HIGH
|
||||
|
||||
stream = self.session.content_feeder().load(
|
||||
playabletrack_id, VorbisOnlyAudioQuality(AudioQuality.NORMAL), False,
|
||||
playabletrack_id, VorbisOnlyAudioQuality(quality), False,
|
||||
None)
|
||||
start = 0
|
||||
end = stream.input_stream.size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue