minidlna.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. -- Copyright 2012 Gabor Juhos <juhosg@openwrt.org>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local m, s, o
  4. m = Map("minidlna", translate("miniDLNA"),
  5. translate("MiniDLNA is server software with the aim of being fully compliant with DLNA/UPnP-AV clients."))
  6. m:section(SimpleSection).template = "minidlna_status"
  7. s = m:section(TypedSection, "minidlna", "miniDLNA Settings")
  8. s.addremove = false
  9. s.anonymous = true
  10. s:tab("general", translate("General Settings"))
  11. s:tab("advanced", translate("Advanced Settings"))
  12. o = s:taboption("general", Flag, "enabled", translate("Enable:"))
  13. o.rmempty = false
  14. function o.cfgvalue(self, section)
  15. return luci.sys.init.enabled("minidlna") and self.enabled or self.disabled
  16. end
  17. function o.write(self, section, value)
  18. if value == "1" then
  19. luci.sys.init.enable("minidlna")
  20. luci.sys.call("/etc/init.d/minidlna start >/dev/null")
  21. else
  22. luci.sys.call("/etc/init.d/minidlna stop >/dev/null")
  23. luci.sys.init.disable("minidlna")
  24. end
  25. return Flag.write(self, section, value)
  26. end
  27. o = s:taboption("general", Value, "port", translate("Port:"),
  28. translate("Port for HTTP (descriptions, SOAP, media transfer) traffic."))
  29. o.datatype = "port"
  30. o.default = 8200
  31. o = s:taboption("general", Value, "interface", translate("Interfaces:"),
  32. translate("Network interfaces to serve."))
  33. o.template = "cbi/network_ifacelist"
  34. o.widget = "checkbox"
  35. o.nocreate = true
  36. function o.cfgvalue(self, section)
  37. local rv = { }
  38. local val = Value.cfgvalue(self, section)
  39. if val then
  40. local ifc
  41. for ifc in val:gmatch("[^,%s]+") do
  42. rv[#rv+1] = ifc
  43. end
  44. end
  45. return rv
  46. end
  47. function o.write(self, section, value)
  48. local rv = { }
  49. local ifc
  50. for ifc in luci.util.imatch(value) do
  51. rv[#rv+1] = ifc
  52. end
  53. Value.write(self, section, table.concat(rv, ","))
  54. end
  55. o = s:taboption("general", Value, "friendly_name", translate("Friendly name:"),
  56. translate("Set this if you want to customize the name that shows up on your clients."))
  57. o.rmempty = true
  58. o.placeholder = "OpenWrt DLNA Server"
  59. o = s:taboption("advanced", Value, "db_dir", translate("Database directory:"),
  60. translate("Set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache."))
  61. o.rmempty = true
  62. o.placeholder = "/var/cache/minidlna"
  63. o = s:taboption("advanced", Value, "log_dir", translate("Log directory:"),
  64. translate("Set this if you would like to specify the directory where you want MiniDLNA to store its log file."))
  65. o.rmempty = true
  66. o.placeholder = "/var/log"
  67. s:taboption("advanced", Flag, "inotify", translate("Enable inotify:"),
  68. translate("Set this to enable inotify monitoring to automatically discover new files."))
  69. s:taboption("advanced", Flag, "enable_tivo", translate("Enable TIVO:"),
  70. translate("Set this to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO."))
  71. o.rmempty = true
  72. o = s:taboption("advanced", Flag, "strict_dlna", translate("Strict to DLNA standard:"),
  73. translate("Set this to strictly adhere to DLNA standards. This will allow server-side downscaling of very large JPEG images, which may hurt JPEG serving performance on (at least) Sony DLNA products."))
  74. o.rmempty = true
  75. o = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL:"))
  76. o.rmempty = true
  77. o.placeholder = "http://192.168.1.1/"
  78. o = s:taboption("advanced", Value, "notify_interval", translate("Notify interval:"),
  79. translate("Notify interval in seconds."))
  80. o.datatype = "uinteger"
  81. o.placeholder = 900
  82. o = s:taboption("advanced", Value, "serial", translate("Announced serial number:"),
  83. translate("Serial number the miniDLNA daemon will report to clients in its XML description."))
  84. o.placeholder = "12345678"
  85. s:taboption("advanced", Value, "model_number", translate("Announced model number:"),
  86. translate("Model number the miniDLNA daemon will report to clients in its XML description."))
  87. o.placholder = "1"
  88. o = s:taboption("advanced", Value, "minissdpsocket", translate("miniSSDP socket:"),
  89. translate("Specify the path to the MiniSSDPd socket."))
  90. o.rmempty = true
  91. o.placeholder = "/var/run/minissdpd.sock"
  92. o = s:taboption("general", ListValue, "root_container", translate("Root container:"))
  93. o:value(".", translate("Standard container"))
  94. o:value("B", translate("Browse directory"))
  95. o:value("M", translate("Music"))
  96. o:value("V", translate("Video"))
  97. o:value("P", translate("Pictures"))
  98. s:taboption("general", DynamicList, "media_dir", translate("Media directories:"),
  99. translate("Set this to the directory you want scanned. If you want to restrict the directory to a specific content type, you can prepend the type ('A' for audio, 'V' for video, 'P' for images), followed by a comma, to the directory (eg. media_dir=A,/mnt/media/Music). Multiple directories can be specified."))
  100. o = s:taboption("general", DynamicList, "album_art_names", translate("Album art names:"),
  101. translate("This is a list of file names to check for when searching for album art."))
  102. o.rmempty = true
  103. o.placeholder = "Cover.jpg"
  104. function o.cfgvalue(self, section)
  105. local rv = { }
  106. local val = Value.cfgvalue(self, section)
  107. if type(val) == "table" then
  108. val = table.concat(val, "/")
  109. elseif not val then
  110. val = ""
  111. end
  112. local file
  113. for file in val:gmatch("[^/%s]+") do
  114. rv[#rv+1] = file
  115. end
  116. return rv
  117. end
  118. function o.write(self, section, value)
  119. local rv = { }
  120. local file
  121. for file in luci.util.imatch(value) do
  122. rv[#rv+1] = file
  123. end
  124. Value.write(self, section, table.concat(rv, "/"))
  125. end
  126. return m