From cbdab26b53a6a30f9a0be99b718d5c63286e7c85 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Wed, 14 Aug 2013 20:23:49 +0200 Subject: [PATCH 1/6] Fix .url files crashing forked-daapd and remove "support" for these. An .url file would lead to a crash due to codectype being null. This is fixed with this commit, but at the same time support for these files is completely removed, since even with the bug fixed .url (and .pls) files would not stream. --- src/filescanner_urlfile.c | 121 -------------------------------------- 1 file changed, 121 deletions(-) delete mode 100644 src/filescanner_urlfile.c diff --git a/src/filescanner_urlfile.c b/src/filescanner_urlfile.c deleted file mode 100644 index 59dd28e4..00000000 --- a/src/filescanner_urlfile.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2009-2010 Julien BLACHE - * - * Rewritten from mt-daapd code: - * Copyright (C) 2003 Ron Pedde (ron@pedde.com) - * - * 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. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include "logger.h" -#include "db.h" -#include "misc.h" -#include "filescanner.h" - - -int -scan_url_file(char *file, struct media_file_info *mfi) -{ - FILE *fp; - char *head; - char *tail; - char buf[256]; - size_t len; - int ret; - - DPRINTF(E_DBG, L_SCAN, "Getting URL file info\n"); - - fp = fopen(file, "r"); - if (!fp) - { - DPRINTF(E_WARN, L_SCAN, "Could not open '%s' for reading: %s\n", file, strerror(errno)); - - return -1; - } - - head = fgets(buf, sizeof(buf), fp); - fclose(fp); - - if (!head) - { - DPRINTF(E_WARN, L_SCAN, "Error reading from file '%s': %s", file, strerror(errno)); - - return -1; - } - - len = strlen(buf); - - if (buf[len - 1] != '\n') - { - DPRINTF(E_WARN, L_SCAN, "URL info in file '%s' too large for buffer\n", file); - - return -1; - } - - while (isspace(buf[len - 1])) - { - len--; - buf[len] = '\0'; - } - - tail = strchr(head, ','); - if (!tail) - { - DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n"); - - return -1; - } - - head = tail + 1; - tail = strchr(head, ','); - if (!tail) - { - DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n"); - - return -1; - } - *tail = '\0'; - - mfi->title = strdup(head); - mfi->url = strdup(tail + 1); - - ret = safe_atou32(buf, &mfi->bitrate); - if (ret < 0) - { - DPRINTF(E_WARN, L_SCAN, "Could not read bitrate\n"); - - return -1; - } - - DPRINTF(E_DBG, L_SCAN," Title: %s\n", mfi->title); - DPRINTF(E_DBG, L_SCAN," Bitrate: %d\n", mfi->bitrate); - DPRINTF(E_DBG, L_SCAN," URL: %s\n", mfi->url); - - mfi->type = strdup("pls"); - /* codectype = NULL */ - mfi->description = strdup("Playlist URL"); - - return 0; -} From 5f041b59ebe24b949128e48efa446d0ab27337a4 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Wed, 14 Aug 2013 20:29:18 +0200 Subject: [PATCH 2/6] Fix .url files crashing forked-daapd and remove "support" for these. An .url file would lead to a crash due to codectype being null. This is fixed with this commit, but at the same time support for these files is completely removed, since even with the bug fixed .url (and .pls) files would not stream. --- src/Makefile.am | 2 +- src/filescanner.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index be8a3553..5f8a4c34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -72,7 +72,7 @@ forked_daapd_SOURCES = main.c \ logger.c logger.h \ conffile.c conffile.h \ filescanner.c filescanner.h \ - filescanner_ffmpeg.c filescanner_urlfile.c filescanner_m3u.c $(ITUNESSRC) \ + filescanner_ffmpeg.c filescanner_m3u.c $(ITUNESSRC) \ mdns_avahi.c mdns.h \ remote_pairing.c remote_pairing.h \ evhttp/http.c evhttp/evhttp.h \ diff --git a/src/filescanner.c b/src/filescanner.c index 4c865a0a..f74e6368 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -181,7 +181,7 @@ fixup_tags(struct media_file_info *mfi) * Default to mpeg4 video/audio for unknown file types * in an attempt to allow streaming of DRM-afflicted files */ - if (strcmp(mfi->codectype, "unkn") == 0) + if (mfi->codectype && strcmp(mfi->codectype, "unkn") == 0) { if (mfi->has_video) { @@ -354,11 +354,9 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation) if ((strcmp(ext, ".pls") == 0) || (strcmp(ext, ".url") == 0)) { - mfi.data_kind = 1; /* url/stream */ + DPRINTF(E_INFO, L_SCAN, "No support for .url and .pls in this version, use .m3u\n"); - ret = scan_url_file(file, &mfi); - if (ret < 0) - goto out; + goto out; } else if ((strcmp(ext, ".png") == 0) || (strcmp(ext, ".jpg") == 0)) From f6f30579302da4c9cf38aaad055423ca3d066839 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Wed, 14 Aug 2013 20:32:46 +0200 Subject: [PATCH 3/6] Fix indentation --- src/filescanner_m3u.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/filescanner_m3u.c b/src/filescanner_m3u.c index 340a3081..ba9f4dd4 100644 --- a/src/filescanner_m3u.c +++ b/src/filescanner_m3u.c @@ -183,19 +183,19 @@ scan_m3u_playlist(char *file) entry = rel_entry; } - filename = m_realpath(entry); - if (!filename) - { - DPRINTF(E_WARN, L_SCAN, "Could not determine real path for '%s': %s\n", entry, strerror(errno)); + filename = m_realpath(entry); + if (!filename) + { + DPRINTF(E_WARN, L_SCAN, "Could not determine real path for '%s': %s\n", entry, strerror(errno)); - continue; - } + continue; + } - ret = db_pl_add_item_bypath(pl_id, filename); - if (ret < 0) - DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename); + ret = db_pl_add_item_bypath(pl_id, filename); + if (ret < 0) + DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename); - free(filename); + free(filename); } free(pl_base); From 4552acba7e41dea151913b075b563a0bf93d4290 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Wed, 14 Aug 2013 23:40:55 +0200 Subject: [PATCH 4/6] Adds support for URLs (streaming) in m3u playlist files. Also added a few file types that the filescanner should ignore. --- src/filescanner.c | 37 +++++++++++++++++++++++++++---------- src/filescanner.h | 8 ++++---- src/filescanner_m3u.c | 14 +++++++++++++- src/main.c | 2 ++ 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/filescanner.c b/src/filescanner.c index f74e6368..fab7ec51 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -66,6 +66,7 @@ struct deferred_pl { char *path; + time_t mtime; struct deferred_pl *next; }; @@ -294,8 +295,8 @@ fixup_tags(struct media_file_info *mfi) } -static void -process_media_file(char *file, time_t mtime, off_t size, int compilation) +void +process_media_file(char *file, time_t mtime, off_t size, int compilation, int url) { struct media_file_info mfi; char *filename; @@ -364,13 +365,28 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation) /* Artwork - don't scan */ goto out; } + else if ((strcmp(ext, ".db") == 0) + || (strcmp(ext, ".ini") == 0)) + { + /* System files - don't scan */ + goto out; + } + else if ((filename[1] == '_') + || (filename[1] == '.')) + { + /* Hidden files - don't scan */ + goto out; + } } /* General case */ if (ret < 0) { ret = scan_metadata_ffmpeg(file, &mfi); - mfi.data_kind = 0; /* real file */ + if (url == 0) + mfi.data_kind = 0; /* real file */ + if (url == 1) + mfi.data_kind = 1; /* url/stream */ } if (ret < 0) @@ -401,7 +417,7 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation) } static void -process_playlist(char *file) +process_playlist(char *file, time_t mtime) { char *ext; @@ -409,7 +425,7 @@ process_playlist(char *file) if (ext) { if (strcmp(ext, ".m3u") == 0) - scan_m3u_playlist(file); + scan_m3u_playlist(file, mtime); #ifdef ITUNES else if (strcmp(ext, ".xml") == 0) scan_itunes_itml(file); @@ -419,7 +435,7 @@ process_playlist(char *file) /* Thread: scan */ static void -defer_playlist(char *path) +defer_playlist(char *path, time_t mtime) { struct deferred_pl *pl; @@ -442,6 +458,7 @@ defer_playlist(char *path) return; } + pl->mtime = mtime; pl->next = playlists; playlists = pl; @@ -458,7 +475,7 @@ process_deferred_playlists(void) { playlists = pl->next; - process_playlist(pl->path); + process_playlist(pl->path, pl->mtime); free(pl->path); free(pl); @@ -487,9 +504,9 @@ process_file(char *file, time_t mtime, off_t size, int compilation, int flags) ) { if (flags & F_SCAN_BULK) - defer_playlist(file); + defer_playlist(file, mtime); else - process_playlist(file); + process_playlist(file, mtime); return; } @@ -502,7 +519,7 @@ process_file(char *file, time_t mtime, off_t size, int compilation, int flags) } /* Not any kind of special file, so let's see if it's a media file */ - process_media_file(file, mtime, size, compilation); + process_media_file(file, mtime, size, compilation, 0); } diff --git a/src/filescanner.h b/src/filescanner.h index a1a835d3..b3522ed4 100644 --- a/src/filescanner.h +++ b/src/filescanner.h @@ -10,15 +10,15 @@ filescanner_init(void); void filescanner_deinit(void); +void +process_media_file(char *file, time_t mtime, off_t size, int compilation, int url); + /* Actual scanners */ int scan_metadata_ffmpeg(char *file, struct media_file_info *mfi); -int -scan_url_file(char *file, struct media_file_info *mfi); - void -scan_m3u_playlist(char *file); +scan_m3u_playlist(char *file, time_t mtime); #ifdef ITUNES void diff --git a/src/filescanner_m3u.c b/src/filescanner_m3u.c index ba9f4dd4..b5af40ef 100644 --- a/src/filescanner_m3u.c +++ b/src/filescanner_m3u.c @@ -41,7 +41,7 @@ void -scan_m3u_playlist(char *file) +scan_m3u_playlist(char *file, time_t mtime) { FILE *fp; struct playlist_info *pli; @@ -165,6 +165,17 @@ scan_m3u_playlist(char *file) buf[len] = '\0'; } + /* Check if line is an URL */ + if (strcmp(buf, "http://") > 0) + { + DPRINTF(E_DBG, L_SCAN, "Playlist contains URL entry\n"); + + filename = strdup(buf); + process_media_file(filename, mtime, 0, 0, 1); + + goto urlexit; + } + /* Absolute vs. relative path */ if (buf[0] == '/') { @@ -191,6 +202,7 @@ scan_m3u_playlist(char *file) continue; } + urlexit: ret = db_pl_add_item_bypath(pl_id, filename); if (ret < 0) DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename); diff --git a/src/main.c b/src/main.c index 085edd82..2ed8add5 100644 --- a/src/main.c +++ b/src/main.c @@ -579,6 +579,7 @@ main(int argc, char **argv) } av_register_all(); + avformat_network_init(); av_log_set_callback(logger_ffmpeg); #if LIBAVFORMAT_VERSION_MAJOR < 53 register_ffmpeg_evbuffer_url_protocol(); @@ -814,6 +815,7 @@ main(int argc, char **argv) signal_block_fail: gcrypt_init_fail: + avformat_network_deinit(); av_lockmgr_register(NULL); ffmpeg_init_fail: From 8260841f1783e17bb4fa5ae0bf44e9f4911d375b Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 15 Aug 2013 20:16:33 +0200 Subject: [PATCH 5/6] Exclude streams/URLs (data_kind = 1) from most listings. --- src/db.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/db.c b/src/db.c index 3b956cd1..98d1b8c5 100644 --- a/src/db.c +++ b/src/db.c @@ -737,9 +737,9 @@ db_build_query_items(struct query_params *qp, char **q) int ret; if (qp->filter) - count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND %s;", qp->filter); + count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s;", qp->filter); else - count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0;"); + count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0;"); if (!count) { @@ -762,13 +762,13 @@ db_build_query_items(struct query_params *qp, char **q) sort = sort_clause[qp->sort]; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s %s;", qp->filter, sort, idx); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s %s %s;", qp->filter, sort, idx); else if (idx) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s %s;", sort, idx); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 %s %s;", sort, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s;", qp->filter, sort); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s %s;", qp->filter, sort); else - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s;", sort); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 %s;", sort); if (!query) { @@ -973,7 +973,7 @@ db_build_query_groups(struct query_params *qp, char **q) char *idx; int ret; - qp->results = db_get_count("SELECT COUNT(DISTINCT f.songalbumid) FROM files f WHERE f.disabled = 0;"); + qp->results = db_get_count("SELECT COUNT(DISTINCT f.songalbumid) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0;"); if (qp->results < 0) return -1; @@ -983,13 +983,13 @@ db_build_query_groups(struct query_params *qp, char **q) return -1; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, idx); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, idx); else if (idx) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, idx); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name;", G_ALBUMS, qp->filter); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 AND %s GROUP BY f.album, g.name;", G_ALBUMS, qp->filter); else - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name;", G_ALBUMS); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 GROUP BY f.album, g.name;", G_ALBUMS); if (!query) { @@ -1015,7 +1015,7 @@ db_build_query_groupitems(struct query_params *qp, char **q) { case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(*) FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); break; default: @@ -1040,7 +1040,7 @@ db_build_query_groupitems(struct query_params *qp, char **q) { case G_ALBUMS: query = sqlite3_mprintf("SELECT f.* FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); break; } @@ -1069,7 +1069,7 @@ db_build_query_group_dirs(struct query_params *qp, char **q) case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1)))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); break; default: @@ -1095,7 +1095,7 @@ db_build_query_group_dirs(struct query_params *qp, char **q) case G_ALBUMS: query = sqlite3_mprintf("SELECT DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); break; } From 68c4650fef853013b6be3e084e9212f5de78ebff Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 15 Aug 2013 21:46:20 +0200 Subject: [PATCH 6/6] Revert "Exclude streams/URLs (data_kind = 1) from most listings." This reverts commit 8260841f1783e17bb4fa5ae0bf44e9f4911d375b. --- src/db.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/db.c b/src/db.c index 98d1b8c5..3b956cd1 100644 --- a/src/db.c +++ b/src/db.c @@ -737,9 +737,9 @@ db_build_query_items(struct query_params *qp, char **q) int ret; if (qp->filter) - count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s;", qp->filter); + count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND %s;", qp->filter); else - count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0;"); + count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0;"); if (!count) { @@ -762,13 +762,13 @@ db_build_query_items(struct query_params *qp, char **q) sort = sort_clause[qp->sort]; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s %s %s;", qp->filter, sort, idx); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s %s;", qp->filter, sort, idx); else if (idx) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 %s %s;", sort, idx); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s %s;", sort, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 AND %s %s;", qp->filter, sort); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s;", qp->filter, sort); else - query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND f.data_kind = 0 %s;", sort); + query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s;", sort); if (!query) { @@ -973,7 +973,7 @@ db_build_query_groups(struct query_params *qp, char **q) char *idx; int ret; - qp->results = db_get_count("SELECT COUNT(DISTINCT f.songalbumid) FROM files f WHERE f.disabled = 0 AND f.data_kind = 0;"); + qp->results = db_get_count("SELECT COUNT(DISTINCT f.songalbumid) FROM files f WHERE f.disabled = 0;"); if (qp->results < 0) return -1; @@ -983,13 +983,13 @@ db_build_query_groups(struct query_params *qp, char **q) return -1; if (idx && qp->filter) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, idx); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, idx); else if (idx) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, idx); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, idx); else if (qp->filter) - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 AND %s GROUP BY f.album, g.name;", G_ALBUMS, qp->filter); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name;", G_ALBUMS, qp->filter); else - query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND f.data_kind = 0 GROUP BY f.album, g.name;", G_ALBUMS); + query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name;", G_ALBUMS); if (!query) { @@ -1015,7 +1015,7 @@ db_build_query_groupitems(struct query_params *qp, char **q) { case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(*) FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; default: @@ -1040,7 +1040,7 @@ db_build_query_groupitems(struct query_params *qp, char **q) { case G_ALBUMS: query = sqlite3_mprintf("SELECT f.* FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; } @@ -1069,7 +1069,7 @@ db_build_query_group_dirs(struct query_params *qp, char **q) case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1)))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; default: @@ -1095,7 +1095,7 @@ db_build_query_group_dirs(struct query_params *qp, char **q) case G_ALBUMS: query = sqlite3_mprintf("SELECT DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" - " WHERE g.id = %d AND f.disabled = 0 AND f.data_kind = 0;", qp->id); + " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; }