Media (Linux): use file name as media name if song title is not available

This commit is contained in:
李通洲 2025-01-10 22:17:36 +08:00
parent 17e3853f38
commit 10c8c1b4bf

View File

@ -8,7 +8,6 @@
#ifdef FF_HAVE_DBUS
#include "common/dbus.h"
#include "common/library.h"
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
{ \
@ -116,10 +115,35 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
if(result->song.length == 0)
{
ffStrbufClear(&result->artist);
ffStrbufClear(&result->album);
ffStrbufClear(&result->url);
return false;
if(result->url.length)
{
const char* fileName = memrchr(result->url.chars, '/', result->url.length);
assert(fileName);
++fileName;
ffStrbufEnsureFixedLengthFree(&result->song, result->url.length - (uint32_t) (fileName - result->url.chars));
for(; *fileName && *fileName != '?'; ++fileName)
{
if (*fileName != '%')
{
ffStrbufAppendC(&result->song, *fileName);
}
else
{
char str[] = { fileName[1], fileName[2], 0 };
if (str[0] == 0 || str[1] == 0)
break;
ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16));
fileName += 2;
}
}
}
else
{
ffStrbufClear(&result->artist);
ffStrbufClear(&result->album);
ffStrbufClear(&result->url);
return false;
}
}
//Set short bus name