* Don't expose album art images in the content directory.
* Support album art name wildcards.
This commit is contained in:
parent
761f62ca26
commit
14a0d1ac98
13
albumart.c
13
albumart.c
@ -107,7 +107,7 @@ update_if_album_art(const char * path)
|
||||
char * match = NULL;
|
||||
char * file = NULL;
|
||||
int ncmp = 0;
|
||||
struct album_art_name_s * album_art_name;
|
||||
int album_art;
|
||||
DIR * dh;
|
||||
struct dirent *dp;
|
||||
enum file_types type = TYPE_UNKNOWN;
|
||||
@ -121,14 +121,10 @@ update_if_album_art(const char * path)
|
||||
}
|
||||
else
|
||||
{
|
||||
ncmp = strrchr(match, '.')-match;
|
||||
ncmp = strrchr(match, '.') - match;
|
||||
}
|
||||
/* Check if this file name matches one of the default album art names */
|
||||
for( album_art_name = album_art_names; album_art_name; album_art_name = album_art_name->next )
|
||||
{
|
||||
if( strcmp(album_art_name->name, match) == 0 )
|
||||
break;
|
||||
}
|
||||
album_art = is_album_art(match);
|
||||
|
||||
dir = dirname(strdup(path));
|
||||
dh = opendir(dir);
|
||||
@ -155,7 +151,7 @@ update_if_album_art(const char * path)
|
||||
continue;
|
||||
if( (*(dp->d_name) != '.') &&
|
||||
(is_video(dp->d_name) || is_audio(dp->d_name)) &&
|
||||
(album_art_name || strncmp(dp->d_name, match, ncmp) == 0) )
|
||||
(album_art || strncmp(dp->d_name, match, ncmp) == 0) )
|
||||
{
|
||||
DPRINTF(E_DEBUG, L_METADATA, "New file %s looks like cover art for %s\n", path, dp->d_name);
|
||||
asprintf(&file, "%s/%s", dir, dp->d_name);
|
||||
@ -249,6 +245,7 @@ check_embedded_art(const char * path, const char * image_data, int image_size)
|
||||
fclose(dstfile);
|
||||
if( nwritten != image_size )
|
||||
{
|
||||
DPRINTF(E_WARN, L_METADATA, "Embedded art error: wrote %d/%d bytes\n", nwritten, image_size);
|
||||
remove(art_path);
|
||||
free(art_path);
|
||||
art_path = NULL;
|
||||
|
@ -475,7 +475,7 @@ image_new_from_jpeg(const char * path, int is_file, const char * buf, int size,
|
||||
if(cinfo.output_components == 3)
|
||||
{
|
||||
ofs = 0;
|
||||
if((ptr = (unsigned char *)malloc(w * 3 * cinfo.rec_outbuf_height)) == NULL)
|
||||
if((ptr = (unsigned char *)malloc(w * 3 * cinfo.rec_outbuf_height + 8)) == NULL)
|
||||
{
|
||||
DPRINTF(E_WARN, L_METADATA, "malloc failed\n");
|
||||
return NULL;
|
||||
|
@ -422,6 +422,12 @@ init(int argc, char * * argv)
|
||||
case UPNPALBUMART_NAMES:
|
||||
for( string = ary_options[i].value; (word = strtok(string, "/")); string = NULL ) {
|
||||
struct album_art_name_s * this_name = calloc(1, sizeof(struct album_art_name_s));
|
||||
int len = strlen(word);
|
||||
if( word[len-1] == '*' )
|
||||
{
|
||||
word[len-1] = '\0';
|
||||
this_name->wildcard = 1;
|
||||
}
|
||||
this_name->name = strdup(word);
|
||||
if( !album_art_names )
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ struct media_dir_s {
|
||||
|
||||
struct album_art_name_s {
|
||||
char * name; /* Base path */
|
||||
uint8_t wildcard;
|
||||
struct album_art_name_s * next;
|
||||
};
|
||||
|
||||
@ -86,7 +87,7 @@ struct client_cache_s {
|
||||
struct in_addr addr;
|
||||
unsigned char mac[6];
|
||||
enum client_types type;
|
||||
u_int32_t flags;
|
||||
uint32_t flags;
|
||||
time_t age;
|
||||
};
|
||||
|
||||
|
@ -65,7 +65,7 @@ readoptionsfile(const char * fname);
|
||||
void
|
||||
freeoptions(void);
|
||||
|
||||
#define MAX_OPTION_VALUE_LEN (80)
|
||||
#define MAX_OPTION_VALUE_LEN (200)
|
||||
struct option
|
||||
{
|
||||
enum upnpconfigoptions id;
|
||||
|
@ -472,6 +472,8 @@ insert_file(char * name, const char * path, const char * parentID, int object)
|
||||
|
||||
if( is_image(name) )
|
||||
{
|
||||
if( is_album_art(name) )
|
||||
return -1;
|
||||
strcpy(base, IMAGE_DIR_ID);
|
||||
strcpy(class, "item.imageItem.photo");
|
||||
detailID = GetImageMetadata(path, name);
|
||||
|
24
utils.c
24
utils.c
@ -28,6 +28,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "minidlnatypes.h"
|
||||
#include "upnpglobalvars.h"
|
||||
#include "log.h"
|
||||
|
||||
int
|
||||
@ -245,6 +246,29 @@ is_playlist(const char * file)
|
||||
return (ends_with(file, ".m3u") || ends_with(file, ".pls"));
|
||||
}
|
||||
|
||||
int
|
||||
is_album_art(const char * name)
|
||||
{
|
||||
struct album_art_name_s * album_art_name;
|
||||
|
||||
/* Check if this file name matches one of the default album art names */
|
||||
for( album_art_name = album_art_names; album_art_name; album_art_name = album_art_name->next )
|
||||
{
|
||||
if( album_art_name->wildcard )
|
||||
{
|
||||
if( strncmp(album_art_name->name, name, strlen(album_art_name->name)) == 0 )
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( strcmp(album_art_name->name, name) == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (album_art_name ? 1 : 0);
|
||||
}
|
||||
|
||||
int
|
||||
resolve_unknown_type(const char * path, enum media_types dir_type)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user