minidlna.lua 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. s:taboption("advanced", Flag, "wide_links", translate("Allow wide links:"),
  73. translate("Set this to allow serving content outside the media root (via symlinks)."))
  74. o.rmempty = true
  75. o = s:taboption("advanced", Flag, "strict_dlna", translate("Strict to DLNA standard:"),
  76. 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."))
  77. o.rmempty = true
  78. o = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL:"))
  79. o.rmempty = true
  80. o.placeholder = "http://192.168.1.1/"
  81. o = s:taboption("advanced", Value, "notify_interval", translate("Notify interval:"),
  82. translate("Notify interval in seconds."))
  83. o.datatype = "uinteger"
  84. o.placeholder = 900
  85. o = s:taboption("advanced", Value, "serial", translate("Announced serial number:"),
  86. translate("Serial number the miniDLNA daemon will report to clients in its XML description."))
  87. o.placeholder = "12345678"
  88. s:taboption("advanced", Value, "model_number", translate("Announced model number:"),
  89. translate("Model number the miniDLNA daemon will report to clients in its XML description."))
  90. o.placholder = "1"
  91. o = s:taboption("advanced", Value, "minissdpsocket", translate("miniSSDP socket:"),
  92. translate("Specify the path to the MiniSSDPd socket."))
  93. o.rmempty = true
  94. o.placeholder = "/var/run/minissdpd.sock"
  95. o = s:taboption("general", ListValue, "root_container", translate("Root container:"))
  96. o:value(".", translate("Standard container"))
  97. o:value("B", translate("Browse directory"))
  98. o:value("M", translate("Music"))
  99. o:value("V", translate("Video"))
  100. o:value("P", translate("Pictures"))
  101. s:taboption("general", DynamicList, "media_dir", translate("Media directories:"),
  102. 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. A,/mnt/media/Music). Multiple directories can be specified."))
  103. o = s:taboption("general", DynamicList, "album_art_names", translate("Album art names:"),
  104. translate("This is a list of file names to check for when searching for album art."))
  105. o.rmempty = true
  106. o.placeholder = "Cover.jpg"
  107. function o.cfgvalue(self, section)
  108. local rv = { }
  109. local val = Value.cfgvalue(self, section)
  110. if type(val) == "table" then
  111. val = table.concat(val, "/")
  112. elseif not val then
  113. val = ""
  114. end
  115. local file
  116. for file in val:gmatch("[^/%s]+") do
  117. rv[#rv+1] = file
  118. end
  119. return rv
  120. end
  121. function o.write(self, section, value)
  122. local rv = { }
  123. local file
  124. for file in luci.util.imatch(value) do
  125. rv[#rv+1] = file
  126. end
  127. Value.write(self, section, table.concat(rv, "/"))
  128. end
  129. return m