install.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Installation
  2. =============
  3. Installing larigira is quite simple. You can install latest version from PyPI
  4. using ``pip install larigira``. Or you can ``git clone
  5. https://git.lattuga.net/boyska/larigira.git`` and run ``python setup.py install``.
  6. As always, the usage of a virtualenv is recommended.
  7. Python greater or equal than 3.4 is supported.
  8. Configuration
  9. ---------------
  10. larigira use MPD in a peculiar way. It can use mpd internal library, but it can
  11. also work with "regular" local files, outside of the library. To do so,
  12. however, it requires you to connect to MPD through the UNIX socket instead of
  13. the TCP port.
  14. So how to create this setup?
  15. inside ``~/.mpdconf``, add the following line::
  16. bind_to_address "~/.mpd/socket"
  17. For larigira, you need to set the ``MPD_HOST`` environment variable to
  18. ``$HOME/.mpd/socket``. If you don't do this, you'll find many lines like these in the logs::
  19. 15:37:10|ERROR[Player:93] Cannot insert song file:///tmp/larigira.1002/audiogen-randomdir-8eoklcee.mp3
  20. Traceback (most recent call last):
  21. File "/home/user/my/ror/larigira/larigira/mpc.py", line 91, in enqueue
  22. mpd_client.addid(uri, insert_pos)
  23. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 629, in decorator
  24. return wrapper(self, name, args, bound_decorator(self, returnValue))
  25. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 254, in _execute
  26. return retval()
  27. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 623, in decorator
  28. return function(self, *args, **kwargs)
  29. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 384, in _fetch_item
  30. pairs = list(self._read_pairs())
  31. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 311, in _read_pairs
  32. pair = self._read_pair(separator)
  33. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 302, in _read_pair
  34. line = self._read_line()
  35. File "/home/user/.virtualenvs/larigira3/lib/python3.5/site-packages/python_mpd2-0.5.5-py3.5.egg/mpd.py", line 291, in _read_line
  36. raise CommandError(error)
  37. mpd.CommandError: [400] {addid} Access denied
  38. Options
  39. ~~~~~~~~~~
  40. Options will be presented "grouped" to make them more easily understandable. This is just for documentation
  41. purposes, they don't need to be divided in the configuration.
  42. Options values are assumed to be JSON formatted. For strings and numbers, this makes no difference. For
  43. booleans, this means that the only valid values are ``true`` and ``false``. For lists and objects, read a JSON
  44. reference or learn from examples.
  45. To set an option, you must set an environment variable with the name ``LARIGIRA_OPTIONNAME``.
  46. General
  47. ^^^^^^^^^^^^^
  48. MPD_HOST
  49. This option let you set the way to connect to your MPD server. Please remind that for complete larigira
  50. operatoin you should set the path to a UNIX domain socket, not ``localhost``
  51. MPD_PORT
  52. If you are not using a socket, but a TCP address (which is *not* suggested), this is how you can specify the
  53. port.
  54. DEBUG
  55. you can set it to ``true`` or ``false``. Defaults to ``false``. Will enable extremely verbose output.
  56. TMPDIR
  57. The base for larigira tmpdir. Please note that larigira will create its own directory inside this
  58. temporary directory. This defaults to the system-wide ``$TMPDIR``, or to ``/tmp/`` if not ``TMPDIR`` is
  59. not set. Choose it wisely, keeping in mind that in this directory a lot of cache files will be stored, and
  60. could therefore require hundreds of MB.
  61. UMASK
  62. Umask affects created files permissions. This is important if you want to pass files to a MPD instance
  63. that is running with a different users. There is no default umask, so that you can apply umask via your
  64. standard system tools.
  65. Events
  66. ^^^^^^^^^
  67. CONTINOUS_AUDIOSPEC
  68. when the playlist is too short, larigira picks something new. How? this is controlled by this variable.
  69. This variable should be set to the JSON representation of an audiospec describing how to generate new
  70. audios. The default is ``{"kind": "mpd", "howmany": 1}``. You could, for example, change it to
  71. ``{ "kind": "randomdir", "paths": ["/var/music"], "howmany": 10}``
  72. or to ``{"kind": "mpd", "howmany": 5, "prefix": "background"}``.
  73. EVENT_FILTERS
  74. See :doc:`eventfilters`
  75. LOG_CONFIG
  76. Path to an INI-formatted file to configure logging. See `python logging documentation
  77. <https://docs.python.org/2/library/logging.config.html#logging-config-dictschema>`_
  78. Internals
  79. ^^^^^^^^^^^^^^
  80. These are options you probably don't want to change, unless you want to debug
  81. CACHING_TIME
  82. larigira needs an estimate on how much time an audiogenerator will need. This option sets this. The
  83. default is 10 (seconds). If you set it too low, the events will be scheduled with some delay
  84. CHECK_SECS
  85. The interval (in seconds) that will trigger a check for the playlist length. Set it too low, and you'll be
  86. consuming resource with no usage. Set it too high and you might miss some moment of playlist shortage.
  87. The default is 20
  88. EVENT_TICK_SECS
  89. The interval (in seconds) that will trigger a check on the events to see if there's something to schedule.
  90. This also determines how much time in advance you can add/delete/change an event for the change to be
  91. effective.
  92. SCRIPTS_PATH
  93. This options controls the path where scripts will be looked for. This is a single path, not a list. The
  94. default is ``$XDG_CONFIG_DIR/larigira/scripts/`` which might boil down to
  95. ``$HOME/.config/larigira/scripts/``
  96. DB_URI
  97. The path to the events database. The default is ``$XDG_CONFIG_DIR/larigira/db.json``
  98. MPD_WAIT_START
  99. When larigira starts, it will try to connect to MPD. If MPD doesn't look ready, larigira will wait until
  100. it is. This makes larigira depend on MPD. However, this also makes it easier to run larigira at boot
  101. without complex dependency on MPD to be fully started and listening. You can disable this behavior setting
  102. this to ``false``
  103. MPD_WAIT_START_RETRYSECS
  104. The behavior described for the previous option requires polling. This variable lets you customize the
  105. polling frequency, expressed in seconds. The default is ``5``.
  106. Web interface
  107. ^^^^^^^^^^^^^^^^
  108. HTTP_ADDRESS
  109. The address that the HTTP interface will listen to; defaults to `0.0.0.0`
  110. HTTP_PORT
  111. The port that the HTTP interface will listen to; defaults to `5000`
  112. FILE_PATH_SUGGESTION
  113. A list of paths. Those paths will be scanned for suggestions in audiogenerator forms.
  114. UI_CALENDAR_FREQUENCY_THRESHOLD
  115. The "calendar" view in the UI will omit events that occur too frequently, to avoid noise. This variable is
  116. the threshold, in seconds. Defaults to 4 hours.
  117. BOOTSTRAP_SERVE_LOCAL
  118. larigira can serve every js and css by itself. However, you might like to make the user download standard
  119. libraries from CDNs. In that case, set this variable to ``false``.
  120. Localization
  121. ++++++++++++++
  122. Localization support in larigira is basic to say the least. However, something can be done.
  123. Dates (not consistently! sigh) are formatted according to locale.
  124. LARIGIRA_BABEL_DEFAULT_LOCALE
  125. The short language code you want to use when the user doesn't specify any. Values are in the form
  126. ``it``, ``en``, ``en-US``...
  127. LARIGIRA_UI_CALENDAR_DATE_FMT
  128. The format to show in ``/db/calendar`` page. The format is specified `here <http://babel.pocoo.org/en/latest/dates.html>`_. Default is ``medium``.
  129. As an example, ``eee dd LLL`` will show ``Sun 10 Mar`` for english, and ``dom 10 mar`` for italian.
  130. Debug and development
  131. ^^^^^^^^^^^^^^^^^^^^^^^
  132. REMOVE_UNUSED_FILES
  133. By default, larigira removes the file it generates, as soon as they are no longer in MPD playlist. There is no good reason to change this behavior, unless you need to debug what's going on. For example, if you want to inspect files. Set this to `false` keep everything.