9 use Log::Any::Adapter Stderr => log_level => 'error';
11 { # autoflush without IO::Handle
12 my $fh = select STDERR;
17 my $feeder = App::MPD::Feeder->new();
20 require App::MPD::Feeder::Command;
21 bless $feeder, 'App::MPD::Feeder::Command';
23 exit $feeder->run(@ARGV);
34 mpd-feeder -- MPD playlist manager with emphasys on diversity
38 Engage daemon mode, keeping the MPD playlist full:
40 mpd-feeder [I<option>...]
42 Perform a single command and return to the OS:
44 mpd-feeder [I<option>...] I<command>
48 C<mpd-feeder> keeps the playlist of MPD full with songs, avoiding songs,
49 artists and albums that have been queued recently. This can be used for
50 listening to large song collections without repetitions that happen with random
51 shuffling or when a given artist has many more songs that the rest.
53 The song list is stored in a PostgreSQL database that is kept updated
54 automatically as the MPD database is updated.
56 The timespans for "recent" queueing are configurable.
60 In daemon mode (with no command given), C<mpd-feeder> connects to MPD, updates
61 its local copy of the song database (but see C<--skip-db-update> option below)
62 and makes sure that the playlist is never left with fewer songs than the
63 configured minimum. Playlist changes are detected when they happen.
65 When a command is given, C<mpd-feeder> does not engage in daemon mode, but
66 returns to the OS after execution.
70 Prints configuration file contents on standard output. Can be used to create
71 skeleton F<mpd-feeder.conf>. Makes no connection to MPD or PostgreSQL.
73 =head2 add-unwanted-artist I<artist name>
75 Adds one artist to toe list of unwanted artists. That list is consulted when a
76 new song needs to be added to MPD's playlist and songs by artists in it are
79 =head2 del-unwanted-artist I<artist name>
81 The reverse of C<add-unwanted-artist>.
83 =head2 list-unwanted-artists
85 Prints the contents of the unwanted artist list, one per line.
87 =head2 add-unwanted-album I<album name> by I<artist name>
89 =head2 del-unwanted-album I<album name> by I<artist name>
91 =head2 list-unwanted-albums
93 Manupulate the list of unwanted albums. Useful when there is a specific album
94 you don't want to listen to, but you don't mind other albums by the same
99 Connects to MPD, and if the playlist is below the configured minimum, adds some
104 Adds one song to the playlist. Ignores the configured minimum playlist length.
110 =item B<--config> I<file>
112 =item B<--cfg> I<file>
114 The configuration file to read at startup.
116 B<Default>: C</etc/mpd-feeder/mpd-feeder.conf>.
118 =item B<--log-level> I<trace|debug|info|notice|warning|error|critical|alert|emergency>
120 Set log verbosity. C<trace> is most talkative, including all exchanges with MPD.
122 =item B<--skip-db-update>
124 Skips the startup sync of the song database from MPD.
126 =item B<--tql> I<number>
128 =item B<--target-queue-length> I<number>
130 Sets the wanted playlist length.
132 =item B<--mpd-host> I<hostname>
134 =item B<--mpd-port> I<number>
136 Parameters for connecting to MPD.
138 =item B<--db-path> I<DSN>
140 =item B<--db-user> I<username>
142 Parameters for connecting to PostgreSQL.
144 =item B<--min-album-interval> I<duration>
146 =item B<--min-song-interval> I<duration>
148 =item B<--min-artist-interval> I<duration>
150 Tunes the minimum time between adding songs from the same album/artist and
151 before re-adding the same song.
153 I<duration> is a text duration, recognised by L<Time::Duration::Parse>.
157 =head1 CONFIGURATION FILE
159 Configuration file is an C<.ini> file with the following sections. You can get
160 a skeleton configuration by executing C<mpd-feeder dump-config>. That will
161 produce a configuration file filled with the default values.
167 =item B<log_level> = I<level>
169 Determines the verboseness of the logging. See L</--log-level> option above.
179 =item B<host> = I<hostname>
181 The host where MPD is running.
183 B<Default>: none. However, L<Net::Async::MPD> defaults to the value of the
184 C<MPD_HOST> environment variable, and if that is empty - C<localhost>.
186 =item B<port> = I<number>
188 The port number where MPD is listening.
190 B<Default>: none. However, L<Net::Async::MPD> defaults to the value of the
191 C<MPD_PORT> environment variable, and if that is empty - C<6600>.
193 =item B<initial-reconnect-delay> = I<duration>
195 =item B<max-reconnect-delay> = I<duration>
197 When the connection to MPD is lost, a delay is inserted before a re-connection
198 attempt is made. The duration of the delay is controlled with these two
199 options. Each delay is a bit longer than the last, starting with the value of
200 <initial-reconnect-delay>, and topped at the value of C<max-reconnect-delay>.
202 When a connection is made, the delay before the next re-connection is reset to
203 C<initial-reconnect-delay>.
205 B<Default>: C<3 seconds> for C<initial-reconnect-delay> and C<2 minutes> for
206 C<max-reconnect-delay>.
214 =item B<target-length> = I<number>
216 The number of songs to always have in the MPD's playlist.
220 =item B<min-song-interval> = I<duration>
222 The minimum amount of time after a song is added to the playlist by
223 B<mpd-feeder>, before it is considered again.
225 B<Default>: C<13 days>
227 =item B<min-album-interval> = I<duration>
229 The minimum amount of time after a song is added to the playlist by
230 B<mpd-feeder> before songs from the same album are considered for addition to
233 B<Default>: C<5 hours>.
235 =item B<min-artist-interval> = I<duration>
237 The minimum amount of time after a song is added to the playlist by
238 B<mpd-feeder> before songs by the same artist are consideret for addition to
241 B<Default>: C<1 hour and 15 minutes>.
249 =item B<path> = I<DSN>
251 PostgresQL database name to use for local storage.
253 B<Default>: C<mpd-feeder>
255 =item B<user> = I<name>
257 PostgreSQL user name to connect as.
261 =item B<password> = I<secret>
263 Password to use when connecting to PostgreSQL.
269 See F<init.sql> file in the distribution for commands to initializa the
272 =head1 COPYRIGHT & LICENSE
274 Copyright © 2021 Damyan Ivanov L<dam+mpdfeeder@ktnx.net>
276 This program is free software; you can redistribute it and/or modify it under
277 the terms of the GNU General Public License version 2 as published by the Free
280 This program is distributed in the hope that it will be useful, but WITHOUT ANY
281 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
282 PARTICULAR PURPOSE. See the GNU General Public License for more details.
284 You should have received a copy of the GNU General Public License along with
285 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
286 Street, Fifth Floor, Boston, MA 02110-1301 USA.