2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2011-01-29 10:13:54 +01:00
|
|
|
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2008-09-07 13:35:01 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-09-07 13:35:01 +02:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2008-09-07 13:35:01 +02:00
|
|
|
#include "song_print.h"
|
2012-08-08 09:15:34 +02:00
|
|
|
#include "time_print.h"
|
2008-10-08 10:49:11 +02:00
|
|
|
#include "song.h"
|
2008-09-07 13:35:01 +02:00
|
|
|
#include "directory.h"
|
|
|
|
#include "tag_print.h"
|
2008-09-07 13:53:55 +02:00
|
|
|
#include "client.h"
|
2009-02-27 19:20:11 +01:00
|
|
|
#include "uri.h"
|
2010-07-25 13:18:57 +02:00
|
|
|
#include "mapper.h"
|
2008-09-07 13:35:01 +02:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
void
|
2009-10-13 18:01:06 +02:00
|
|
|
song_print_uri(struct client *client, struct song *song)
|
2008-09-07 13:35:01 +02:00
|
|
|
{
|
2009-01-04 19:08:52 +01:00
|
|
|
if (song_in_database(song) && !directory_is_root(song->parent)) {
|
2008-09-07 13:53:55 +02:00
|
|
|
client_printf(client, "%s%s/%s\n", SONG_FILE,
|
2009-10-13 18:01:06 +02:00
|
|
|
directory_get_path(song->parent), song->uri);
|
2008-09-07 13:35:01 +02:00
|
|
|
} else {
|
2009-02-27 19:20:11 +01:00
|
|
|
char *allocated;
|
|
|
|
const char *uri;
|
|
|
|
|
2009-10-13 18:01:06 +02:00
|
|
|
uri = allocated = uri_remove_auth(song->uri);
|
2009-02-27 19:20:11 +01:00
|
|
|
if (uri == NULL)
|
2009-10-13 18:01:06 +02:00
|
|
|
uri = song->uri;
|
2009-02-27 19:20:11 +01:00
|
|
|
|
2010-07-25 13:18:57 +02:00
|
|
|
client_printf(client, "%s%s\n", SONG_FILE,
|
|
|
|
map_to_relative_path(uri));
|
2009-02-27 19:20:11 +01:00
|
|
|
|
|
|
|
g_free(allocated);
|
2008-09-07 13:35:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-08 10:21:15 +01:00
|
|
|
void
|
2008-10-08 10:49:11 +02:00
|
|
|
song_print_info(struct client *client, struct song *song)
|
2008-09-07 13:35:01 +02:00
|
|
|
{
|
2009-10-13 18:01:06 +02:00
|
|
|
song_print_uri(client, song);
|
2008-09-07 13:35:01 +02:00
|
|
|
|
2010-06-25 20:02:53 +02:00
|
|
|
if (song->end_ms > 0)
|
|
|
|
client_printf(client, "Range: %u.%03u-%u.%03u\n",
|
|
|
|
song->start_ms / 1000,
|
|
|
|
song->start_ms % 1000,
|
|
|
|
song->end_ms / 1000,
|
|
|
|
song->end_ms % 1000);
|
|
|
|
else if (song->start_ms > 0)
|
|
|
|
client_printf(client, "Range: %u.%03u-\n",
|
|
|
|
song->start_ms / 1000,
|
|
|
|
song->start_ms % 1000);
|
2009-12-25 22:59:13 +01:00
|
|
|
|
2012-08-08 09:15:34 +02:00
|
|
|
if (song->mtime > 0)
|
|
|
|
time_print(client, "Last-Modified", song->mtime);
|
2009-07-05 08:40:29 +02:00
|
|
|
|
2008-09-07 13:35:01 +02:00
|
|
|
if (song->tag)
|
2008-09-07 13:53:55 +02:00
|
|
|
tag_print(client, song->tag);
|
2008-09-07 13:35:01 +02:00
|
|
|
}
|