Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librespot: enable streaming to Kodi #1735

Merged
merged 2 commits into from Jul 6, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="@PKG_ADDON_ID@"
name="@ADDON_NAME@"
version="@ADDON_VERSION@"
provider-name="@PROVIDER_NAME@">
<requires>
<import addon="os.libreelec.tv" version="@OS_VERSION@"/>
<import addon="xbmc.python" version="2.1.0"/>
@REQUIRES@
</requires>
<extension point="xbmc.service" library="default.py">
<provides>@PKG_ADDON_PROVIDES@</provides>
</extension>
<extension point="xbmc.python.library" library="addon.py">
<provides></provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary>@PKG_SHORTDESC@</summary>
<description>
@PKG_LONGDESC@
</description>
<disclaimer>
@PKG_DISCLAIMER@
</disclaimer>
<platform>all</platform>
<news>
@PKG_ADDON_NEWS@
</news>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.png</fanart>
@PKG_ADDON_SCREENSHOT@
</assets>
</extension>
</addon>
@@ -1,2 +1,5 @@
101
- Enable streaming to Kodi

100
- Initial addon
@@ -18,20 +18,21 @@
################################################################################

PKG_NAME="librespot"
PKG_VERSION="2259188"
PKG_REV="100"
PKG_VERSION="67deb07"
PKG_REV="101"
PKG_ARCH="any"
PKG_LICENSE="prop."
PKG_LICENSE="MIT"
PKG_SITE="https://github.com/plietar/$PKG_NAME/"
PKG_URL="https://github.com/plietar/$PKG_NAME/archive/$PKG_VERSION.zip"
PKG_DEPENDS_TARGET="toolchain avahi libvorbis pyalsaaudio rust"
PKG_DEPENDS_TARGET="toolchain avahi ffmpegx libvorbis pyalsaaudio rust"
PKG_SECTION="service"
PKG_LONGDESC="Librespot ($PKG_VERSION) plays Spotify through LibreELEC using the opensource librespot library using a Spotify app as a remote."
PKG_SHORTDESC="Librespot: play Spotify through LibreELEC using a Spotify app as a remote"
PKG_LONGDESC="Librespot ($PKG_VERSION) plays Spotify through LibreELEC using the open source librespot library using a Spotify app as a remote."
PKG_AUTORECONF="no"

PKG_IS_ADDON="yes"
PKG_ADDON_NAME="Librespot"
PKG_ADDON_TYPE="xbmc.service"
PKG_ADDON_TYPE="xbmc.service.library"
PKG_MAINTAINER="Anton Voyl (awiouy)"

configure_target() {
@@ -43,22 +44,25 @@ configure_target() {
make_target() {
cd src
$CARGO_BUILD --no-default-features --features "alsa-backend with-avahi"
cd "$ROOT/$PKG_BUILD/.$TARGET_NAME"/*/release
$STRIP librespot
}

makeinstall_target() {
:
}

addon() {
mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID"
cp "$(get_build_dir pyalsaaudio)/.install_pkg/usr/lib/python2.7/site-packages/alsaaudio.so" \
"$ADDON_BUILD/$PKG_ADDON_ID"

mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/bin"
cp "$PKG_BUILD/.$TARGET_NAME"/*/release/librespot \
"$(get_build_dir ffmpegx)/.install_pkg/usr/local/bin/ffmpegx" \
"$ADDON_BUILD/$PKG_ADDON_ID/bin"

mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/lib"
cp "$(get_build_dir avahi)/avahi-compat-libdns_sd/.libs/libdns_sd.so.1" \
"$ADDON_BUILD/$PKG_ADDON_ID/lib"

mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/wizard"
cp "$(get_build_dir pyalsaaudio)/.install_pkg/usr/lib/python2.7/site-packages/alsaaudio.so" \
"$ADDON_BUILD/$PKG_ADDON_ID/wizard/"
}

This file was deleted.

@@ -16,24 +16,8 @@
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

import alsaaudio as alsa
import xbmcaddon
import xbmcgui
from default import addon as addon

if __name__ == '__main__':

addon = xbmcaddon.Addon('service.librespot')
dialog = xbmcgui.Dialog()
strings = addon.getLocalizedString

while True:
pcms = alsa.pcms()[1:]
if len(pcms) == 0:
dialog.ok(strings(30211), strings(30212))
break
pcmx = dialog.select(strings(30113), pcms)
if pcmx == -1:
break
pcm = pcms[pcmx]
addon.setSetting('ls_o', pcm)
break
if __name__ == '__main__':
addon()
@@ -17,10 +17,6 @@
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################

. /etc/os-release
. /etc/profile
oe_setup_addon service.librespot

activate_card() {
if [ -e "/proc/asound/$1" ]; then
return
@@ -39,62 +35,83 @@ activate_card() {
esac
}

if [ ! "$(cat /proc/asound/pcm 2> /dev/null)" ]; then
case "$LIBREELEC_ARCH" in
RPi*.arm)
activate_card "ALSA"
init_alsa() {
. /etc/os-release

if [ ! "$(cat /proc/asound/pcm 2> /dev/null)" ]; then
case "$LIBREELEC_ARCH" in
RPi*.arm)
activate_card "ALSA"
;;
*)
echo "Unable to activate an audio interface on $LIBREELEC_ARCH"
exit
;;
esac
fi

case "$ls_o" in
*:CARD=*)
card="${ls_o##*:CARD=}"
card="${card%%,*}"
activate_card "$card"
index="$(readlink /proc/asound/$card)"
index="${index##*card}"
;;
hw:*,*)
echo "The hw:d,s specification is unreliable, use device:CARD=card instead"
index="${ls_o##hw:}"
index="${index%%,*}"
card="card$index"
activate_card "$card"
;;
*)
echo "Unable to activate an audio interface on $LIBREELEC_ARCH"
exit
if [ -n "$ls_o" ]; then
echo "Unknown playback device specification $ls_o"
fi
;;
esac
fi

case "$ls_o" in
*:CARD=*)
card="${ls_o##*:CARD=}"
card="${card%%,*}"
activate_card "$card"
index="$(readlink /proc/asound/$card)"
index="${index##*card}"
;;
hw:*,*)
echo "The hw:d,s specification is unreliable, use device:CARD=card instead"
index="${ls_o##hw:}"
index="${index%%,*}"
card="card$index"
activate_card "$card"
;;
*)
if [ -n "$ls_o" ]; then
echo "Unknown playback device specification $ls_o"
fi
;;
esac
case "$LIBREELEC_ARCH" in
RPi*.arm)
[ "$(readlink /proc/asound/ALSA)" == "card$index" ] && [ "$pcm_3" ] &&
amixer -c "$index" cset name="PCM Playback Route" "$pcm_3"
;;
esac
}

if [ -n "$ls_b" -a "$ls_b" != "-" ]; then
bitrate="--bitrate $ls_b"
fi

if [ -n "$ls_o" ]; then
device="--device $ls_o"
. /etc/profile
oe_setup_addon service.librespot

LIBRESPOT="librespot --cache \"$ADDON_HOME/cache\"
--disable-audio-cache \
--name \"Librespot@$HOSTNAME\""

if [ -n "$ls_b" -a "$ls_b" != "-" ]; then
LIBRESPOT="$LIBRESPOT --bitrate $ls_b"
fi

if [ -n "$ls_p" -a -n "$ls_u" ]; then
discovery="--disable-discovery --password $ls_p --username $ls_u"
LIBRESPOT="$LIBRESPOT --disable-discovery \
--password \"$ls_p\" \
--username \"$ls_u\""
fi

case "$LIBREELEC_ARCH" in
RPi*.arm)
[ "$(readlink /proc/asound/ALSA)" == "card$index" ] && [ "$pcm_3" ] &&
amixer -c "$index" cset name="PCM Playback Route" "$pcm_3"
;;
esac
if [ "$ls_O" == "Kodi" ]; then
LIBRESPOT="$LIBRESPOT --backend pipe \
--onstart=\"kodi-send \
--action=RunAddon(service.librespot)\" \
| ffmpegx -hide_banner -loglevel warning \
-avioflags direct -fflags nobuffer \
-re -ac 2 -ar 44100 -channel_layout stereo -f s16le -i pipe: \
-sdp_file \"$ADDON_HOME/librespot.sdp\" \
-f rtp rtp://127.0.0.1:5555"
else
init_alsa
if [ -n "$ls_o" ]; then
LIBRESPOT="$LIBRESPOT --device \"$ls_o\""
fi
fi

librespot $bitrate \
--cache "$ADDON_HOME/cache" \
$device \
--disable-audio-cache \
$discovery \
--name "Librespot@$HOSTNAME"
eval $LIBRESPOT
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.