it only works on premium accounts dont read the code or commits i swear

This commit is contained in:
cere 2024-02-21 04:45:15 -05:00
parent 7888e685ec
commit 9e397dc673
11 changed files with 46 additions and 5 deletions

View file

@ -5,9 +5,9 @@ Uses 'bottle' and 'librespot-python' for playback, and 'spotipy' for the playlis
Thanks to kokarare1212 for creating ['librespot-python'](https://github.com/kokarare1212/librespot-python/).
This a fork of the [glk1001](https://github.com/glk1001/plugin.audio.spotify) version, modified to work with librespot-python instead of spotty.
This a fork of the [glk1001](https://github.com/glk1001/plugin.audio.spotify) addon, modified to work with librespot-python instead of spotty.
It may take some disabling/re-enabling the addon to get it to generate the initial authorization token. Dunno why.
It may take some disabling/re-enabling the addon (or just reopening it a few times) to get it to generate the initial authorization token. Dunno why.
## Support
None, like my Piped addon this is for personal use. If you wanna update it, fork it (and let me know if you end up doing so!)

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Passwort"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Neuerscheinungen"

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr ""
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr ""

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Contraseña"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Nuevos Lanzamientos"

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Contraseña"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Nuevos Lanzamientos"

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Contraseña"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Nuevos Lanzamientos"

View file

@ -24,6 +24,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Mot de passe"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Nouveautés"

View file

@ -25,6 +25,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "ססמה"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "שיחרורים חדשים"

View file

@ -25,6 +25,10 @@ msgctxt "#11002"
msgid "Password"
msgstr "Wachtwoord"
msgctxt "#11003"
msgid "Premium Account"
msgstr ""
msgctxt "#11005"
msgid "New releases"
msgstr "Nieuwe releases"

View file

@ -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

View file

@ -3,6 +3,7 @@
<category label="11028">
<setting id="username" type="text" default="" label="11001"/>
<setting id="password" type="text" default="" option="hidden" label="11002"/>
<setting id="isPremium" type="bool" default="false" label="11003"/>
</category>
<category label="11055">