jellyfin ok
This commit is contained in:
parent
8e2f09b317
commit
b37c092f7a
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_VERSION:=1.1.5-20220729
|
PKG_VERSION:=1.1.5-20221110
|
||||||
PKG_RELEASE:=
|
PKG_RELEASE:=
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI support for jellyfin
|
LUCI_TITLE:=LuCI support for jellyfin
|
||||||
|
@ -3,6 +3,7 @@ LuCI - Lua Configuration Interface
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
local taskd = require "luci.model.tasks"
|
local taskd = require "luci.model.tasks"
|
||||||
|
local jellyfin_model = require "luci.model.jellyfin"
|
||||||
local m, s, o
|
local m, s, o
|
||||||
|
|
||||||
m = taskd.docker_map("jellyfin", "jellyfin", "/usr/share/jellyfin/install.sh",
|
m = taskd.docker_map("jellyfin", "jellyfin", "/usr/share/jellyfin/install.sh",
|
||||||
@ -26,14 +27,28 @@ o.default = "8096"
|
|||||||
o.datatype = "port"
|
o.datatype = "port"
|
||||||
o:depends("hostnet", 0)
|
o:depends("hostnet", 0)
|
||||||
|
|
||||||
o = s:option(Value, "media_path", translate("Media path"))
|
local blocks = jellyfin_model.blocks()
|
||||||
o.datatype = "string"
|
local home = jellyfin_model.home()
|
||||||
|
|
||||||
o = s:option(Value, "config_path", translate("Config path").."<b>*</b>")
|
o = s:option(Value, "config_path", translate("Config path").."<b>*</b>")
|
||||||
o.rmempty = false
|
o.rmempty = false
|
||||||
o.datatype = "string"
|
o.datatype = "string"
|
||||||
|
|
||||||
o = s:option(Value, "cache_path", translate("Transcode cache path"), translate("Default use 'transcodes' in 'config path' if not set, please make sure there has enough space"))
|
local paths, default_path = jellyfin_model.find_paths(blocks, home, "Configs")
|
||||||
|
for _, val in pairs(paths) do
|
||||||
|
o:value(val, val)
|
||||||
|
end
|
||||||
|
o.default = default_path
|
||||||
|
|
||||||
|
o = s:option(Value, "media_path", translate("Media path"), translate("Not required, all disk is mounted in") .. " <a href='/cgi-bin/luci/admin/services/linkease/file#/?path=/root/mnt' target='_blank'>/mnt</a>")
|
||||||
o.datatype = "string"
|
o.datatype = "string"
|
||||||
|
|
||||||
|
o = s:option(Value, "cache_path", translate("Transcode cache path"), translate("Default use 'transcodes' in 'config path' if not set, please make sure there has enough space"))
|
||||||
|
o.datatype = "string"
|
||||||
|
local paths, default_path = jellyfin_model.find_paths(blocks, home, "Caches")
|
||||||
|
for _, val in pairs(paths) do
|
||||||
|
o:value(val, val)
|
||||||
|
end
|
||||||
|
o.default = default_path
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
54
applications/luci-app-jellyfin/luasrc/model/jellyfin.lua
Normal file
54
applications/luci-app-jellyfin/luasrc/model/jellyfin.lua
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
local util = require "luci.util"
|
||||||
|
local jsonc = require "luci.jsonc"
|
||||||
|
|
||||||
|
local jellyfin = {}
|
||||||
|
|
||||||
|
jellyfin.blocks = function()
|
||||||
|
local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r")
|
||||||
|
local vals = {}
|
||||||
|
if f then
|
||||||
|
local ret = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
local obj = jsonc.parse(ret)
|
||||||
|
for _, val in pairs(obj["blockdevices"]) do
|
||||||
|
local fsize = val["fssize"]
|
||||||
|
if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then
|
||||||
|
-- fsize > 1G
|
||||||
|
vals[#vals+1] = val["mountpoint"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return vals
|
||||||
|
end
|
||||||
|
|
||||||
|
jellyfin.home = function()
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
|
local home_dirs = {}
|
||||||
|
home_dirs["main_dir"] = uci:get_first("quickstart", "main", "main_dir", "/root")
|
||||||
|
home_dirs["Configs"] = uci:get_first("quickstart", "main", "conf_dir", home_dirs["main_dir"].."/Configs")
|
||||||
|
home_dirs["Downloads"] = uci:get_first("quickstart", "main", "dl_dir", home_dirs["main_dir"].."/Downloads")
|
||||||
|
home_dirs["Caches"] = uci:get_first("quickstart", "main", "tmp_dir", home_dirs["main_dir"].."/Caches")
|
||||||
|
return home_dirs
|
||||||
|
end
|
||||||
|
|
||||||
|
jellyfin.find_paths = function(blocks, home_dirs, path_name)
|
||||||
|
local default_path = ''
|
||||||
|
local configs = {}
|
||||||
|
|
||||||
|
default_path = home_dirs[path_name] .. "/Jellyfin"
|
||||||
|
if #blocks == 0 then
|
||||||
|
table.insert(configs, default_path)
|
||||||
|
else
|
||||||
|
for _, val in pairs(blocks) do
|
||||||
|
table.insert(configs, val .. "/" .. path_name .. "/Jellyfin")
|
||||||
|
end
|
||||||
|
local without_conf_dir = "/root/" .. path_name .. "/Jellyfin"
|
||||||
|
if default_path == without_conf_dir then
|
||||||
|
default_path = configs[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return configs, default_path
|
||||||
|
end
|
||||||
|
|
||||||
|
return jellyfin
|
@ -51,3 +51,6 @@ msgstr "Jellyfin 未运行"
|
|||||||
|
|
||||||
msgid "Open Jellyfin"
|
msgid "Open Jellyfin"
|
||||||
msgstr "打开 Jellyfin"
|
msgstr "打开 Jellyfin"
|
||||||
|
|
||||||
|
msgid "Not required, all disk is mounted in"
|
||||||
|
msgstr "可不填,所有硬盘都在"
|
||||||
|
@ -3,5 +3,5 @@ config jellyfin
|
|||||||
option 'port' '8096'
|
option 'port' '8096'
|
||||||
option 'image' 'default'
|
option 'image' 'default'
|
||||||
option 'media_path' ''
|
option 'media_path' ''
|
||||||
option 'config_path' '/root/jellyfin/config'
|
option 'config_path' '/root/Config/Jellyfin'
|
||||||
option 'cache_path' ''
|
option 'cache_path' ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user