minidlna.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. 'use strict';
  2. 'require view';
  3. 'require fs';
  4. 'require uci';
  5. 'require form';
  6. 'require tools.widgets as widgets';
  7. var CBIMiniDLNAStatus = form.DummyValue.extend({
  8. load: function() {
  9. var port = +uci.get_first('minidlna', 'minidlna', 'port');
  10. if (isNaN(port) || port < 0 || port > 65535)
  11. port = 8200;
  12. return L.resolveDefault(fs.exec_direct('/usr/bin/wget', [ '-q', 'http://127.0.0.1:%d/'.format(port), '-O', '-' ]), null)
  13. .then(L.bind(function(html) {
  14. if (html == null) {
  15. this.default = E('em', {}, [ _('The miniDLNA service is not running.') ]);
  16. }
  17. else {
  18. var audio = html.match(/Audio files<\/td><td>(\d+)/),
  19. video = html.match(/Video files<\/td><td>(\d+)/),
  20. image = html.match(/Image files<\/td><td>(\d+)/);
  21. this.default = _('The miniDLNA service is active, serving %d audio, %d video and %d image files.')
  22. .format(audio ? +audio[1] : 0, video ? +video[1] : 0, image ? +image[1] : 0);
  23. }
  24. }, this));
  25. }
  26. });
  27. return view.extend({
  28. render: function() {
  29. var m, s, o;
  30. m = new form.Map('minidlna', _('miniDLNA'), _('MiniDLNA is server software with the aim of being fully compliant with DLNA/UPnP-AV clients.'));
  31. s = m.section(form.TypedSection);
  32. s.title = _('Status');
  33. s.anonymous = true;
  34. s.cfgsections = function() { return [ '_status' ] };
  35. o = s.option(CBIMiniDLNAStatus);
  36. s = m.section(form.TypedSection, 'minidlna', 'miniDLNA Settings');
  37. s.anonymous = true;
  38. s.addremove = false;
  39. s.tab('general', _('General Settings'));
  40. s.tab('advanced', _('Advanced Settings'));
  41. o = s.taboption('general', form.Flag, 'enabled', _('Enable'));
  42. o = s.taboption('general', form.Value, 'port', _('Port'),
  43. _('Port for HTTP (descriptions, SOAP, media transfer) traffic.'));
  44. o.default = '8200';
  45. o = s.taboption('general', widgets.DeviceSelect, 'interface', _('Interfaces'), _('Network interfaces to serve.'));
  46. o.multiple = true;
  47. o.noaliases = true;
  48. o.cfgvalue = function(section_id) {
  49. return L.toArray(uci.get('minidlna', section_id, 'interface')).join(',').split(/[ \t,]+/);
  50. };
  51. o.write = function(section_id, value) {
  52. return uci.set('minidlna', section_id, 'interface', L.toArray(value).join(','));
  53. };
  54. o = s.taboption('general', form.Value, 'friendly_name', _('Friendly name'), _('Set this if you want to customize the name that shows up on your clients.'));
  55. o = s.taboption('general', form.ListValue, 'root_container', _('Root container'));
  56. o.value('.', _('Standard container'));
  57. o.value('B', _('Browse directory'));
  58. o.value('M', _('Music'));
  59. o.value('V', _('Video'));
  60. o.value('P', _('Pictures'));
  61. o = s.taboption('general', form.DynamicList, 'media_dir', _('Media directories'), _('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.'));
  62. o = s.taboption('advanced', form.DynamicList, 'album_art_names', _('Album art names'), _('This is a list of file names to check for when searching for album art.'));
  63. o.cfgvalue = function(section_id) {
  64. return L.toArray(uci.get('minidlna', section_id, 'album_art_names')).join('/').split(/\//);
  65. };
  66. o.write = function(section_id, value) {
  67. return uci.set('minidlna', section_id, 'album_art_names', L.toArray(value).join('/'));
  68. };
  69. o = s.taboption('advanced', form.Value, 'db_dir', _('Database directory'), _('Set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache.'));
  70. o = s.taboption('advanced', form.Flag, 'inotify', _('Enable inotify'), _('Set this to enable inotify monitoring to automatically discover new files.'));
  71. o = s.taboption('advanced', form.Flag, 'enable_tivo', _('Enable TIVO'), _('Set this to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO.'));
  72. o = s.taboption('advanced', form.Flag, 'wide_links', _('Allow wide links'), _('Set this to allow serving content outside the media root (via symlinks).'));
  73. o = s.taboption('advanced', form.Flag, 'strict_dlna', _('Strict to DLNA standard'), _('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 = s.taboption('advanced', form.Value, 'presentation_url', _('Presentation URL'));
  75. o = s.taboption('advanced', form.Value, 'notify_interval', _('Notify interval'), _('Notify interval in seconds.'));
  76. o.placeholder = '900';
  77. o = s.taboption('advanced', form.Value, 'serial', _('Announced serial number'), _('Serial number the miniDLNA daemon will report to clients in its XML description.'));
  78. o.placeholder = '12345678';
  79. o = s.taboption('advanced', form.Value, 'uuid', _('Announced UUID'));
  80. o.placeholder = '019f9a56-ff60-44c0-9edc-eae88d09fa05';
  81. o = s.taboption('advanced', form.Value, 'model_number', _('Announced model number'), _('Model number the miniDLNA daemon will report to clients in its XML description.'));
  82. o.placeholder = '1';
  83. o = s.taboption('advanced', form.Value, 'minissdpsocket', _('miniSSDP socket'), _('Specify the path to the MiniSSDPd socket.'));
  84. return m.render();
  85. }
  86. });