Skip to content

Commit

Permalink
Media (Linux): use file name as media name if song title is not avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
CarterLi committed Jan 10, 2025
1 parent 17e3853 commit 10c8c1b
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions src/detection/media/media_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#ifdef FF_HAVE_DBUS
#include "common/dbus.h"
#include "common/library.h"

#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
{ \
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 10c8c1b

Please sign in to comment.