Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

jsonrpc: ensure that "label" always contains at least the filename of…

… a playing item
  • Loading branch information...
commit db911a5f88ef054840b3dc3b98bf342845361506 1 parent 80bb9b9
@Montellese Montellese authored
View
54 xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -555,35 +555,39 @@ JSONRPC_STATUS CAudioLibrary::Clean(const CStdString &method, ITransportLayer *t
bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
CMusicDatabase musicdatabase;
- if (strFilename.empty() || !musicdatabase.Open())
+ if (strFilename.empty())
return false;
- if (CDirectory::Exists(strFilename))
+ bool filled = false;
+ if (musicdatabase.Open())
{
- CAlbum album;
- int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
- if (!musicdatabase.GetAlbumInfo(albumid, album, NULL))
- return false;
-
- item->SetFromAlbum(album);
-
- CFileItemList items;
- items.Add(item);
- if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) != OK)
- return false;
- }
- else
- {
- CSong song;
- if (!musicdatabase.GetSongByFileName(strFilename, song))
- return false;
+ if (CDirectory::Exists(strFilename))
+ {
+ CAlbum album;
+ int albumid = musicdatabase.GetAlbumIdByPath(strFilename);
+ if (musicdatabase.GetAlbumInfo(albumid, album, NULL))
+ {
+ item->SetFromAlbum(album);
- item->SetFromSong(song);
+ CFileItemList items;
+ items.Add(item);
+ if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) == OK)
+ filled = true;
+ }
+ }
+ else
+ {
+ CSong song;
+ if (musicdatabase.GetSongByFileName(strFilename, song))
+ {
+ item->SetFromSong(song);
- CFileItemList items;
- items.Add(item);
- if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) != OK)
- return false;
+ CFileItemList items;
+ items.Add(item);
+ if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) == OK)
+ filled = true;
+ }
+ }
}
if (item->GetLabel().empty())
@@ -593,7 +597,7 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
item->SetLabel(URIUtils::GetFileName(strFilename));
}
- return true;
+ return filled;
}
bool CAudioLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemList &list)
View
6 xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -389,8 +389,12 @@ bool CFileItemHandler::FillFileItemList(const CVariant &parameterObject, CFileIt
picture.Load(item->GetPath());
*item->GetPictureInfoTag() = picture;
}
- if (item->GetLabel().IsEmpty())
+ if (item->GetLabel().empty())
+ {
item->SetLabel(CUtil::GetTitleFromPath(file, false));
+ if (item->GetLabel().empty())
+ item->SetLabel(URIUtils::GetFileName(file));
+ }
list.Add(item);
}
}
View
12 xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -123,7 +123,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
{
const CVideoInfoTag *currentVideoTag = g_infoManager.GetCurrentMovieTag();
if (currentVideoTag != NULL)
- fileItem = CFileItemPtr(new CFileItem(*currentVideoTag));
+ {
+ CStdString originalLabel = fileItem->GetLabel();
+ fileItem->SetFromVideoInfoTag(*currentVideoTag);
+ if (fileItem->GetLabel().empty())
+ fileItem->SetLabel(originalLabel);
+ }
fileItem->SetPath(g_application.CurrentFileItem().GetPath());
}
}
@@ -133,7 +138,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
{
const MUSIC_INFO::CMusicInfoTag *currentMusicTag = g_infoManager.GetCurrentSongTag();
if (currentMusicTag != NULL)
+ {
+ CStdString originalLabel = fileItem->GetLabel();
fileItem = CFileItemPtr(new CFileItem(*currentMusicTag));
+ if (fileItem->GetLabel().empty())
+ fileItem->SetLabel(originalLabel);
+ }
fileItem->SetPath(g_application.CurrentFileItem().GetPath());
}
}
View
21 xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -691,21 +691,28 @@ JSONRPC_STATUS CVideoLibrary::Clean(const CStdString &method, ITransportLayer *t
bool CVideoLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant &parameterObject /* = CVariant(CVariant::VariantTypeArray) */)
{
CVideoDatabase videodatabase;
- if (strFilename.empty() || !videodatabase.Open())
- return false;
-
- CVideoInfoTag details;
- if (!videodatabase.LoadVideoInfo(strFilename, details))
+ if (strFilename.empty())
return false;
+
+ bool filled = false;
+ if (videodatabase.Open())
+ {
+ CVideoInfoTag details;
+ if (videodatabase.LoadVideoInfo(strFilename, details))
+ {
+ item->SetFromVideoInfoTag(details);
+ filled = true;
+ }
+ }
- item->SetFromVideoInfoTag(details);
if (item->GetLabel().empty())
{
item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
if (item->GetLabel().empty())
item->SetLabel(URIUtils::GetFileName(strFilename));
}
- return true;
+
+ return filled;
}
bool CVideoLibrary::FillFileItemList(const CVariant &parameterObject, CFileItemList &list)
Please sign in to comment.
Something went wrong with that request. Please try again.