From 7b250deeb2b49ee81e4c0f2dd876f3b8c6e53428 Mon Sep 17 00:00:00 2001 From: lean Date: Mon, 6 Apr 2020 14:03:52 +0800 Subject: [PATCH] luci-app-music-remote-center: DAAP remote control music server for iOS/Android --- .../luci-app-music-remote-center/Makefile | 18 ++++++ .../luasrc/controller/forked-daapd.lua | 21 ++++++ .../luasrc/model/cbi/forked-daapd.lua | 31 +++++++++ .../view/forked-daapd/forked-daapd_status.htm | 22 +++++++ .../po/zh-cn/forked-daapd.po | 59 +++++++++++++++++ .../root/etc/config/forked-daapd | 7 ++ .../root/etc/init.d/forked-daapd | 64 +++++++++++++++++++ .../root/etc/uci-defaults/forked-daapd | 11 ++++ 8 files changed, 233 insertions(+) create mode 100644 package/lean/luci-app-music-remote-center/Makefile create mode 100644 package/lean/luci-app-music-remote-center/luasrc/controller/forked-daapd.lua create mode 100644 package/lean/luci-app-music-remote-center/luasrc/model/cbi/forked-daapd.lua create mode 100644 package/lean/luci-app-music-remote-center/luasrc/view/forked-daapd/forked-daapd_status.htm create mode 100644 package/lean/luci-app-music-remote-center/po/zh-cn/forked-daapd.po create mode 100644 package/lean/luci-app-music-remote-center/root/etc/config/forked-daapd create mode 100755 package/lean/luci-app-music-remote-center/root/etc/init.d/forked-daapd create mode 100644 package/lean/luci-app-music-remote-center/root/etc/uci-defaults/forked-daapd diff --git a/package/lean/luci-app-music-remote-center/Makefile b/package/lean/luci-app-music-remote-center/Makefile new file mode 100644 index 000000000..a0b835910 --- /dev/null +++ b/package/lean/luci-app-music-remote-center/Makefile @@ -0,0 +1,18 @@ +# +# Copyright (C) 2008-2014 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Luci for Music Remote Center +LUCI_DEPENDS:=+alsa-utils +forked-daapd +LUCI_PKGARCH:=all +PKG_VERSION:=1 +PKG_RELEASE:=1 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/package/lean/luci-app-music-remote-center/luasrc/controller/forked-daapd.lua b/package/lean/luci-app-music-remote-center/luasrc/controller/forked-daapd.lua new file mode 100644 index 000000000..744c54e8f --- /dev/null +++ b/package/lean/luci-app-music-remote-center/luasrc/controller/forked-daapd.lua @@ -0,0 +1,21 @@ + + +module("luci.controller.forked-daapd", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/forked-daapd") then + return + end + + entry({"admin", "nas", "forked-daapd"}, cbi("forked-daapd"), _("Music Remote Center")).dependent = true + + entry({"admin","nas","forked-daapd","run"},call("act_status")).leaf=true + +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep forked-daapd >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end \ No newline at end of file diff --git a/package/lean/luci-app-music-remote-center/luasrc/model/cbi/forked-daapd.lua b/package/lean/luci-app-music-remote-center/luasrc/model/cbi/forked-daapd.lua new file mode 100644 index 000000000..188cb1f5b --- /dev/null +++ b/package/lean/luci-app-music-remote-center/luasrc/model/cbi/forked-daapd.lua @@ -0,0 +1,31 @@ +-- Copyright 2020 Lean +-- Licensed to the public under the Apache License 2.0. + +m = Map("forked-daapd", translate("Music Remote Center"), translate("Music Remote Center is a DAAP (iTunes Remote), MPD (Music Player Daemon) and RSP (Roku) media server.")) + +m:section(SimpleSection).template = "forked-daapd/forked-daapd_status" + +s = m:section(TypedSection, "forked-daapd") +s.addremove = false +s.anonymous = true + +enable=s:option(Flag, "enabled", translate("Enabled")) +enable.default = "0" +enable.rmempty = false + +port=s:option(Value, "port", translate("Port")) +port.rmempty = false +port.datatype = "port" + +db_path=s:option(Value, "db_path", translate("Database File Path")) +db_path.default = "/opt/forked-daapd-songs3.db" +db_path.rmempty = false + +directories=s:option(Value, "directories", translate("Music Directorie Path")) +directories.default = "/opt/music" +directories.rmempty = false + +readme=s:option(DummyValue,"readme",translate("Readme")) +readme.description=translate("About iOS Remote Pairing:
1. Open the web interface
2. Start iPhone Remote APP, go to Settings, Add Library
3. Enter the pair code in the web interface") + +return m \ No newline at end of file diff --git a/package/lean/luci-app-music-remote-center/luasrc/view/forked-daapd/forked-daapd_status.htm b/package/lean/luci-app-music-remote-center/luasrc/view/forked-daapd/forked-daapd_status.htm new file mode 100644 index 000000000..2663987d8 --- /dev/null +++ b/package/lean/luci-app-music-remote-center/luasrc/view/forked-daapd/forked-daapd_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
\ No newline at end of file diff --git a/package/lean/luci-app-music-remote-center/po/zh-cn/forked-daapd.po b/package/lean/luci-app-music-remote-center/po/zh-cn/forked-daapd.po new file mode 100644 index 000000000..973fa31ca --- /dev/null +++ b/package/lean/luci-app-music-remote-center/po/zh-cn/forked-daapd.po @@ -0,0 +1,59 @@ +msgid "" +msgstr "" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-23 20:16+0800\n" +"PO-Revision-Date: 2015-06-23 20:17+0800\n" +"Last-Translator: coolsnowwolf \n" +"Language-Team: PandoraBox Team\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 1.8.1\n" +"X-Poedit-SourceCharset: UTF-8\n" + +msgid "AirPlay 2 Receiver" +msgstr "AirPlay 2 音频接收器" + +msgid "Respawn" +msgstr "进程守护" + +msgid "Apple AirPlay 2 Receiver" +msgstr "Apple AirPlay 2 无损音频接收服务器" + +msgid "Apple AirPlay 2 Receiver is a simple AirPlay server implementation" +msgstr "Apple AirPlay 2 是一个强大易用的无损音频服务器( iOS/MacOSX 原生支持)" + +msgid "Airport Name" +msgstr "音频接收器名称" + +msgid "Password Auth" +msgstr "开启密码认证" + +msgid "Interpolation" +msgstr "音频重采样" + +msgid "Internal Basic Resampler" +msgstr "内置" + +msgid "High quality SoX Resampler" +msgstr "高质量 SoX 采样器(需要强力的CPU)" + +msgid "Alsa Output Device" +msgstr "音频输出设备" + +msgid "Alsa Mixer Control Name" +msgstr "硬件音量控制器名称" + +msgid "1st Soundcard" +msgstr "第 1 张声卡" + +msgid "2nd Soundcard" +msgstr "第 2 张声卡" + +msgid "Alsa Output Rate" +msgstr "音频输出采样率" + +msgid "Alsa Buffer Length" +msgstr "音频缓冲区长度" diff --git a/package/lean/luci-app-music-remote-center/root/etc/config/forked-daapd b/package/lean/luci-app-music-remote-center/root/etc/config/forked-daapd new file mode 100644 index 000000000..78fee16ea --- /dev/null +++ b/package/lean/luci-app-music-remote-center/root/etc/config/forked-daapd @@ -0,0 +1,7 @@ + +config forked-daapd + option port '3689' + option directories '/opt/music' + option enabled '0' + option db_path '/opt/songs.db' + diff --git a/package/lean/luci-app-music-remote-center/root/etc/init.d/forked-daapd b/package/lean/luci-app-music-remote-center/root/etc/init.d/forked-daapd new file mode 100755 index 000000000..1c8d75d62 --- /dev/null +++ b/package/lean/luci-app-music-remote-center/root/etc/init.d/forked-daapd @@ -0,0 +1,64 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2020 OpenWrt.org + +START=99 +BIN=/usr/sbin/forked-daapd +PID=/var/run/forked-daapd.pid +SSD=start-stop-daemon + +NAME=forked-daapd + +uci_get_by_name() { + local ret=$(uci get $NAME.$1.$2 2>/dev/null) + echo ${ret:=$3} +} + +uci_get_by_type() { + local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null) + echo ${ret:=$3} +} + +gen_config_file() { +cat <<-EOF >/var/etc/forked-daapd.conf +general { + uid = "root" + db_path = "/opt/forked-daapd-songs3.db" + logfile = "/var/log/forked-daapd.log" + loglevel = log + ipv6 = no + cache_path = "/var/forked-daapd-cache.db" +} + +library { + name = "My Music on OpenWrt" + port = $(uci_get_by_type forked-daapd port 3689) + directories = { "$(uci_get_by_type forked-daapd directories)" } + podcasts = { "/Podcasts" } + audiobooks = { "/Audiobooks" } + compilations = { "/Compilations" } + compilation_artist = "Various Artists" +} + +audio { + nickname = "Local Audio Output" + type = "alsa" +} +EOF +} + +start() { + gen_config_file + local enabled=$(uci_get_by_type forked-daapd enabled 0) + [ "$enabled" == "0" ] && return 1 + $SSD -p $PID -S -x $BIN -- -P $PID -c /var/etc/forked-daapd.conf +} + +stop() { + $SSD -p $PID -K -s SIGINT >/dev/null +} + +restart() { + stop + sleep 2 + start +} diff --git a/package/lean/luci-app-music-remote-center/root/etc/uci-defaults/forked-daapd b/package/lean/luci-app-music-remote-center/root/etc/uci-defaults/forked-daapd new file mode 100644 index 000000000..c3e1a59ee --- /dev/null +++ b/package/lean/luci-app-music-remote-center/root/etc/uci-defaults/forked-daapd @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@forked-daapd[-1] + add ucitrack forked-daapd + set ucitrack.@forked-daapd[-1].init=forked-daapd + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0