mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 07:05:57 -05:00
Adds looking for artwork named [directory name].{png,jpg}
This commit is contained in:
parent
0b571765d3
commit
48b7cd9a05
7
README
7
README
@ -223,15 +223,22 @@ As for the naming convention, it is quite simple; consider your foo.mp3 song,
|
||||
residing at /bar/foo.mp3:
|
||||
- if /bar/foo.{png,jpg} exists, this will be used as the artwork for this file;
|
||||
- failing that, if /bar/{artwork,cover}.{png,jpg} exists, it will be used.
|
||||
- failing that, if /bar/bar.{png,jpg} exists, it will be used
|
||||
|
||||
For "groups" (same album name and album artist), the situation is a bit
|
||||
different:
|
||||
- if a file {artwork,cover}.{png,jpg} is found in one of the directories
|
||||
containing files that are part of the group, it is used as the artwork. The
|
||||
first file found is used, ordering is not guaranteed;
|
||||
- failing that, if [directory name].{png,jpg} is found in one of the
|
||||
directories containing files that are part of the group, it is used as the
|
||||
artwork. The first file found is used, ordering is not guaranteed;
|
||||
- failing that, individual files are examined and the first artwork found is
|
||||
used. Here again, ordering is not guaranteed.
|
||||
|
||||
{artwork,cover} are the default, you can add other base names in the
|
||||
configuration file.
|
||||
|
||||
You can use symlinks for the artwork files; the artwork is not scanned/indexed
|
||||
in any way in the database and there is no caching on forked-daapd's side.
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
static const char *cover_extension[] =
|
||||
{
|
||||
"png", "jpg",
|
||||
"jpg", "png",
|
||||
};
|
||||
|
||||
|
||||
@ -728,6 +728,64 @@ artwork_get_dir_image(char *path, int isdir, int max_w, int max_h, int format, s
|
||||
return artwork_get(artwork, max_w, max_h, format, evbuf);
|
||||
}
|
||||
|
||||
static int
|
||||
artwork_get_parentdir_image(char *path, int isdir, int max_w, int max_h, int format, struct evbuffer *evbuf)
|
||||
{
|
||||
char artwork[PATH_MAX];
|
||||
char parentdir[PATH_MAX];
|
||||
char *ptr;
|
||||
int len;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
ret = snprintf(artwork, sizeof(artwork), "%s", path);
|
||||
if ((ret < 0) || (ret >= sizeof(artwork)))
|
||||
{
|
||||
DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!isdir)
|
||||
{
|
||||
ptr = strrchr(artwork, '/');
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
ptr = strrchr(artwork, '/');
|
||||
if ((!ptr) || (strlen(ptr) <= 1))
|
||||
return -1;
|
||||
strcpy(parentdir, ptr + 1);
|
||||
|
||||
len = strlen(artwork);
|
||||
|
||||
for (i = 0; i < (sizeof(cover_extension) / sizeof(cover_extension[0])); i++)
|
||||
{
|
||||
ret = snprintf(artwork + len, sizeof(artwork) - len, "/%s.%s", parentdir, cover_extension[i]);
|
||||
if ((ret < 0) || (ret >= sizeof(artwork) - len))
|
||||
{
|
||||
DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX (%s.%s)\n", parentdir, cover_extension[i]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
DPRINTF(E_DBG, L_ART, "Trying parent directory artwork file %s\n", artwork);
|
||||
|
||||
ret = access(artwork, F_OK);
|
||||
if (ret < 0)
|
||||
continue;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == (sizeof(cover_extension) / sizeof(cover_extension[0])))
|
||||
return -1;
|
||||
|
||||
return artwork_get(artwork, max_w, max_h, format, evbuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf)
|
||||
@ -746,6 +804,11 @@ artwork_get_item_filename(char *filename, int max_w, int max_h, int format, stru
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
|
||||
/* Look for parentdir(filename).{png,jpg} */
|
||||
ret = artwork_get_parentdir_image(filename, 0, max_w, max_h, format, evbuf);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -800,6 +863,8 @@ artwork_get_group(int id, int max_w, int max_h, int format, struct evbuffer *evb
|
||||
while ((got_art < 0) && ((ret = db_query_fetch_string(&qp, &dir)) == 0) && (dir))
|
||||
{
|
||||
got_art = artwork_get_dir_image(dir, 1, max_w, max_h, format, evbuf);
|
||||
if (got_art < 0)
|
||||
got_art = artwork_get_parentdir_image(dir, 1, max_w, max_h, format, evbuf);
|
||||
}
|
||||
|
||||
db_query_end(&qp);
|
||||
|
Loading…
Reference in New Issue
Block a user