Permalink
Browse files

Merge pull request #4105 from Montellese/fix_musicvideos_artists_albums

Only show albums of the selected musicvideo artist
  • Loading branch information...
jmarshallnz committed Jan 31, 2014
2 parents b2969b3 + e1c47e8 commit 1b62b15c6c57e7bfd0a24fab6db2d4574d18bd70
@@ -21,6 +21,7 @@
#include "DirectoryNodeGrouped.h"
#include "QueryParams.h"
#include "video/VideoDatabase.h"
+#include "video/VideoDbUrl.h"
using namespace XFILE::VIDEODATABASEDIRECTORY;
@@ -68,7 +69,12 @@ bool CDirectoryNodeGrouped::GetContent(CFileItemList& items) const
if (itemType.empty())
return false;
- return videodatabase.GetItems(BuildPath(), (VIDEODB_CONTENT_TYPE)params.GetContentType(), itemType, items);
+ // make sure to translate all IDs in the path into URL parameters
+ CVideoDbUrl videoUrl;
+ if (!videoUrl.FromString(BuildPath()))
+ return false;
+
+ return videodatabase.GetItems(videoUrl.ToString(), (VIDEODB_CONTENT_TYPE)params.GetContentType(), itemType, items);
}
std::string CDirectoryNodeGrouped::GetContentType() const
@@ -77,6 +77,7 @@ bool CDirectoryNodeMusicVideosOverview::GetContent(CFileItemList& items) const
pItem->m_bIsFolder = true;
pItem->SetCanQueue(false);
+ pItem->SetSpecialSort(SortSpecialOnTop);
items.Add(pItem);
}
@@ -5219,20 +5219,23 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
+ CVideoDbUrl videoUrl;
+ if (!videoUrl.FromString(strBaseDir))
+ return false;
+
CStdString strSQL = "select %s from musicvideoview ";
Filter extFilter = filter;
+ extFilter.fields = PrepareSQL("musicvideoview.c%02d, musicvideoview.idMVideo, actors.strActor", VIDEODB_ID_MUSICVIDEO_ALBUM);
+ extFilter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo"));
+ extFilter.AppendJoin(PrepareSQL("join actors on actors.idActor = artistlinkmusicvideo.idArtist"));
if (CProfilesManager::Get().GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && !g_passwordManager.bMasterUser)
{
- extFilter.fields = PrepareSQL("musicvideoview.c%02d, musicvideoview.idMVideo, actors.strActor, path.strPath", VIDEODB_ID_MUSICVIDEO_ALBUM);
- extFilter.AppendJoin("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo join actors on actors.idActor = artistlinkmusicvideo.idArtist join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath");
- }
- else
- {
- extFilter.fields = PrepareSQL("musicvideoview.c%02d, musicvideoview.idMVideo, actors.strActor", VIDEODB_ID_MUSICVIDEO_ALBUM);
- extFilter.AppendJoin("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo join actors on actors.idActor = artistlinkmusicvideo.idArtist");
+ extFilter.fields += " path.strPath";
+ extFilter.AppendJoin("join files on files.idFile = musicvideoview.idFile join path on path.idPath = files.idPath");
}
+
if (idArtist > -1)
- extFilter.AppendWhere(PrepareSQL("artistlinkmusicvideo.idArtist = %i", idArtist));
+ videoUrl.AddOption("artistid", idArtist);
extFilter.AppendGroup(PrepareSQL("musicvideoview.c%02d", VIDEODB_ID_MUSICVIDEO_ALBUM));
@@ -5244,8 +5247,7 @@ bool CVideoDatabase::GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileI
}
strSQL = StringUtils::Format(strSQL.c_str(), !extFilter.fields.empty() ? extFilter.fields.c_str() : "*");
- CVideoDbUrl videoUrl;
- if (!BuildSQL(strBaseDir, strSQL, extFilter, strSQL, videoUrl))
+ if (!BuildSQL(videoUrl.ToString(), strSQL, extFilter, strSQL, videoUrl))
return false;
int iRowsFound = RunQuery(strSQL);
@@ -9870,14 +9872,19 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription
option = options.find("artistid");
if (option != options.end())
{
- filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo"));
+ if (itemType != "albums")
+ filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo"));
filter.AppendWhere(PrepareSQL("artistlinkmusicvideo.idArtist = %i", (int)option->second.asInteger()));
}
option = options.find("artist");
if (option != options.end())
{
- filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo join actors on actors.idActor = artistlinkmusicvideo.idArtist"));
+ if (itemType != "albums")
+ {
+ filter.AppendJoin(PrepareSQL("join artistlinkmusicvideo on artistlinkmusicvideo.idMVideo = musicvideoview.idMVideo"));
+ filter.AppendJoin(PrepareSQL("join actors on actors.idActor = artistlinkmusicvideo.idArtist"));
+ }
filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str()));
}
@@ -161,7 +161,13 @@ bool CVideoDbUrl::parse()
// add options based on the QueryParams
if (queryParams.GetActorId() != -1)
- AddOption("actorid", (int)queryParams.GetActorId());
+ {
+ std::string optionName = "actorid";
+ if (m_type == "musicvideos")
+ optionName = "artistid";
+
+ AddOption(optionName, (int)queryParams.GetActorId());
+ }
if (queryParams.GetAlbumId() != -1)
AddOption("albumid", (int)queryParams.GetAlbumId());
if (queryParams.GetCountryId() != -1)

0 comments on commit 1b62b15

Please sign in to comment.