jellyfin: initial release

Co-authored-by: CvH <1355173+CvH@users.noreply.github.com>
This commit is contained in:
heitbaum 2021-07-10 03:05:45 +00:00
parent ded9079630
commit b273f59ada
10 changed files with 203 additions and 0 deletions

View File

@ -0,0 +1,2 @@
100
- Initial release

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="jellyfin"
PKG_VERSION="1.0"
PKG_VERSION_NUMBER="10.7.6"
PKG_REV="100"
PKG_ARCH="any"
PKG_LICENSE="GPLv2"
PKG_SITE="https://jellyfin.org/"
PKG_DEPENDS_TARGET="toolchain"
PKG_SECTION="service"
PKG_SHORTDESC="Jellyfin: The Free Software Media System"
PKG_LONGDESC="Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. Stream to any device from your own server. Your media, your server, your way."
PKG_TOOLCHAIN="manual"
PKG_IS_ADDON="yes"
PKG_ADDON_NAME="Jellyfin"
PKG_ADDON_TYPE="xbmc.service"
PKG_ADDON_REQUIRES="tools.ffmpeg-tools:0.0.0 tools.dotnet-runtime:0.0.0"
PKG_ADDON_PROVIDES="executable"
make_target() {
:
}
addon() {
:
}
post_install_addon() {
sed -e "s/@JELLYFIN_VERSION@/${PKG_VERSION_NUMBER}/g" -i "${INSTALL}/bin/jellyfin-downloader"
}

View File

@ -0,0 +1,65 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
. /etc/profile
oe_setup_addon service.jellyfin
ICON="$ADDON_DIR/resources/icon.png"
CONTROL_FILE="/tmp/curl.done"
DATA_FILE="/tmp/curl.data"
JELLYFIN_FILE="jellyfin_@JELLYFIN_VERSION@.tar.gz"
# check for enough free disk space
if [ $(df . | awk 'END {print $4}') -lt 200000 ]; then
kodi-send --action="Notification(Not enough disk space, at least 200MB are required,30000,${ICON})" >/dev/null
exit 0;
fi
# remove install status and folders
if [ -f $ADDON_DIR/extract.ok ]; then
rm $ADDON_DIR/extract.ok
fi
if [ -d $ADDON_DIR/libs ]; then
rm -rf $ADDON_DIR/libs
fi
if [ -d $ADDON_DIR/tmp_download ]; then
rm -rf $ADDON_DIR/tmp_download
fi
# create tmp download dir
mkdir -p $ADDON_DIR/tmp_download
cd $ADDON_DIR/tmp_download
echo "Downloading Jellyfin"
# download Jellyfin
rm -f ${CONTROL_FILE} ${DATA_FILE}
(
curl -L -# -O -C - https://repo.jellyfin.org/releases/server/portable/versions/stable/combined/@JELLYFIN_VERSION@/${JELLYFIN_FILE} 2>${DATA_FILE}
touch ${CONTROL_FILE}
) | \
while [ : ]; do
[ -f ${DATA_FILE} ] && prog="$(tr '\r' '\n' < ${DATA_FILE} | tail -n 1 | sed -r 's/^[# ]+/#/;s/^[^0-9]*//g')" || prog=
kodi-send --action="Notification(Downloading Jellyfin,\"${prog:-0.0%}\",3000,${ICON})" >/dev/null
[ -f ${CONTROL_FILE} ] && break
sleep 4
done
rm -f ${CONTROL_FILE} ${DATA_FILE}
# extract Jellyfin
kodi-send --action="Notification(Extracting Jellyfin,Starting,1000,${ICON})" >/dev/null
# extract JELLYFIN_FILE to libs directory
mkdir $ADDON_DIR/libs
tar xf ${JELLYFIN_FILE} -C $ADDON_DIR/libs --strip-components=2
# cleanup
cd $ADDON_DIR
rm -rf $ADDON_DIR/tmp_download
touch $ADDON_DIR/extract.ok
kodi-send --action="Notification(Extracting Jellyfin,Finished,1000,${ICON})" >/dev/null

View File

@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
. /etc/profile
oe_setup_addon service.jellyfin
# check if jellyfin is already successful installed
if [ ! -f "$ADDON_DIR/extract.ok" ]; then
cd $ADDON_DIR
jellyfin-downloader
fi
libs="${ADDON_DIR}/libs"
ff="/storage/.kodi/addons/tools.ffmpeg-tools/bin"
exec \
nice -n "$jellyfin_nice" \
dotnet "${libs}/jellyfin.dll" \
--datadir "${ADDON_HOME}" \
--ffmpeg "${ff}/ffmpeg"

View File

@ -0,0 +1,46 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
import json
import subprocess
import xbmc
import xbmcaddon
import xbmcgui
def jsonrpc(request):
return json.loads(xbmc.executeJSONRPC(json.dumps(request)))
def disable_conflicting(conficting,
message='{that} conflicts with {this} and has been disabled'):
is_enabled = {'jsonrpc': '2.0', 'method': 'Addons.GetAddonDetails', 'id': 1,
'params': {'addonid': conficting, 'properties': ['enabled']}}
disable = {'jsonrpc': '2.0', 'method': 'Addons.SetAddonEnabled', 'id': 1,
'params': {'addonid': conficting, 'enabled': False}}
try:
if jsonrpc(is_enabled)['result']['addon']['enabled']:
this = xbmcaddon.Addon().getAddonInfo('name')
that = xbmcaddon.Addon(conficting).getAddonInfo('name')
jsonrpc(disable)
dialog = xbmcgui.Dialog()
dialog.ok(this, message.format(
this=this, that=that))
del dialog
except KeyError:
pass
class Monitor(xbmc.Monitor):
def __init__(self, *args, **kwargs):
xbmc.Monitor.__init__(self)
self.id = xbmcaddon.Addon().getAddonInfo('id')
def onSettingsChanged(self):
subprocess.call(['systemctl', 'restart', self.id])
if __name__ == '__main__':
disable_conflicting('service.emby')
Monitor().waitForAbort()

View File

@ -0,0 +1,14 @@
# Kodi Media Center language file
# Addon Name: jellyfin
# Addon id: service.jellyfin
# Addon Provider: Team LibreELEC
msgid ""
msgstr ""
msgctxt "#30000"
msgid "Configuration"
msgstr ""
msgctxt "#30001"
msgid "Priority (nice, 0=max, 19=min)"
msgstr ""

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="30000">
<setting label="30001" id="jellyfin_nice" type="slider" default="10" range="0,1,19" option="int" />
</category>
</settings>

View File

@ -0,0 +1,3 @@
<settings version="2">
<setting id="jellyfin_nice" default="true">10</setting>
</settings>

View File

@ -0,0 +1,13 @@
[Unit]
Description=Jellyfin - The Free Software Media System
Documentation=https://jellyfin.org/
Wants=multi-user.target
After=multi-user.target
[Service]
SyslogIdentifier=%N
ExecStart=/bin/sh /storage/.kodi/addons/%N/bin/jellyfin-start
Restart=always
[Install]
WantedBy=multi-user.target