Skip to content

Commit 10c8c1b

Browse files
committed
Media (Linux): use file name as media name if song title is not available
1 parent 17e3853 commit 10c8c1b

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/detection/media/media_linux.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#ifdef FF_HAVE_DBUS
1010
#include "common/dbus.h"
11-
#include "common/library.h"
1211

1312
#define FF_DBUS_ITER_CONTINUE(dbus, iterator) \
1413
{ \
@@ -116,10 +115,35 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
116115

117116
if(result->song.length == 0)
118117
{
119-
ffStrbufClear(&result->artist);
120-
ffStrbufClear(&result->album);
121-
ffStrbufClear(&result->url);
122-
return false;
118+
if(result->url.length)
119+
{
120+
const char* fileName = memrchr(result->url.chars, '/', result->url.length);
121+
assert(fileName);
122+
++fileName;
123+
ffStrbufEnsureFixedLengthFree(&result->song, result->url.length - (uint32_t) (fileName - result->url.chars));
124+
for(; *fileName && *fileName != '?'; ++fileName)
125+
{
126+
if (*fileName != '%')
127+
{
128+
ffStrbufAppendC(&result->song, *fileName);
129+
}
130+
else
131+
{
132+
char str[] = { fileName[1], fileName[2], 0 };
133+
if (str[0] == 0 || str[1] == 0)
134+
break;
135+
ffStrbufAppendC(&result->song, (char) strtoul(str, NULL, 16));
136+
fileName += 2;
137+
}
138+
}
139+
}
140+
else
141+
{
142+
ffStrbufClear(&result->artist);
143+
ffStrbufClear(&result->album);
144+
ffStrbufClear(&result->url);
145+
return false;
146+
}
123147
}
124148

125149
//Set short bus name

0 commit comments

Comments
 (0)