mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-28 15:06:02 -05:00
Handle sort tags in fixup_tags()
Ensure the sort tags are filled and normalized.
This commit is contained in:
parent
373c5584af
commit
3162028c41
@ -37,6 +37,8 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <uninorm.h>
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
# include <sys/inotify.h>
|
# include <sys/inotify.h>
|
||||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
@ -132,6 +134,24 @@ pop_dir(struct stacked_dir **s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
normalize_fixup_tag(char **tag, char *src_tag)
|
||||||
|
{
|
||||||
|
char *norm;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* Note: include terminating NUL in string length for u8_normalize */
|
||||||
|
|
||||||
|
if (!*tag)
|
||||||
|
*tag = (char *)u8_normalize(UNINORM_NFD, (uint8_t *)src_tag, strlen(src_tag) + 1, NULL, &len);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
norm = (char *)u8_normalize(UNINORM_NFD, (uint8_t *)*tag, strlen(*tag) + 1, NULL, &len);
|
||||||
|
free(*tag);
|
||||||
|
*tag = norm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fixup_tags(struct media_file_info *mfi)
|
fixup_tags(struct media_file_info *mfi)
|
||||||
{
|
{
|
||||||
@ -247,6 +267,16 @@ fixup_tags(struct media_file_info *mfi)
|
|||||||
else
|
else
|
||||||
mfi->album_artist = strdup(mfi->artist);
|
mfi->album_artist = strdup(mfi->artist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure sort tags are filled and normalized */
|
||||||
|
normalize_fixup_tag(&mfi->artist_sort, mfi->artist);
|
||||||
|
normalize_fixup_tag(&mfi->album_sort, mfi->album);
|
||||||
|
normalize_fixup_tag(&mfi->title_sort, mfi->title);
|
||||||
|
normalize_fixup_tag(&mfi->album_artist_sort, mfi->album_artist);
|
||||||
|
|
||||||
|
/* Composer is not one of our mandatory tags, so take extra care */
|
||||||
|
if (mfi->composer_sort || mfi->composer)
|
||||||
|
normalize_fixup_tag(&mfi->composer_sort, mfi->composer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user