aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormontellese <montellese@xbmc.org>2012-09-09 15:59:45 +0200
committermontellese <montellese@xbmc.org>2012-09-09 15:59:45 +0200
commit9cd1f6ec0d4766306ca10c61542e7d2a3239358f (patch)
tree62c076e42a5a4b9f214d2991bcde0ce6b49bbdd1
parentd576adeff3b25b29fbed5972fa5e5d971f8160db (diff)
videolibrary: add tag support for tvshows
-rw-r--r--system/library/video/tvshows/tags.xml5
-rw-r--r--xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTags.cpp9
-rw-r--r--xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp2
-rw-r--r--xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp1
-rw-r--r--xbmc/interfaces/json-rpc/VideoLibrary.cpp2
-rw-r--r--xbmc/video/VideoDatabase.cpp32
-rw-r--r--xbmc/video/VideoDatabase.h4
-rw-r--r--xbmc/video/windows/GUIWindowVideoNav.cpp109
8 files changed, 114 insertions, 50 deletions
diff --git a/system/library/video/tvshows/tags.xml b/system/library/video/tvshows/tags.xml
new file mode 100644
index 0000000000..ad2a6e4fa8
--- /dev/null
+++ b/system/library/video/tvshows/tags.xml
@@ -0,0 +1,5 @@
+<node order="6" type="folder">
+ <label>20459</label>
+ <path>videodb://2/9</path>
+ <icon>DefaultTags.png</icon>
+</node>
diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTags.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTags.cpp
index d95da74ff4..5f94d144ba 100644
--- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTags.cpp
+++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTags.cpp
@@ -33,7 +33,14 @@ CDirectoryNodeTags::CDirectoryNodeTags(const CStdString& strName, CDirectoryNode
NODE_TYPE CDirectoryNodeTags::GetChildType() const
{
- return NODE_TYPE_TITLE_MOVIES;
+ CQueryParams params;
+ CollectQueryParams(params);
+ if (params.GetContentType() == VIDEODB_CONTENT_MOVIES)
+ return NODE_TYPE_TITLE_MOVIES;
+ if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS)
+ return NODE_TYPE_TITLE_MUSICVIDEOS;
+
+ return NODE_TYPE_TITLE_TVSHOWS;
}
CStdString CDirectoryNodeTags::GetLocalizedName() const
diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp
index c0f6b3b4a7..23b995d665 100644
--- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp
+++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp
@@ -53,7 +53,7 @@ bool CDirectoryNodeTitleTvShows::GetContent(CFileItemList& items) const
CQueryParams params;
CollectQueryParams(params);
- bool bSuccess=videodatabase.GetTvShowsNav(BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetStudioId());
+ bool bSuccess=videodatabase.GetTvShowsNav(BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetStudioId(), params.GetTagId());
videodatabase.Close();
diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp
index 75db3cf3d7..86623ac438 100644
--- a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp
+++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp
@@ -32,6 +32,7 @@ Node TvShowChildren[] = {
{ NODE_TYPE_YEAR, 3, 562 },
{ NODE_TYPE_ACTOR, 4, 344 },
{ NODE_TYPE_STUDIO, 5, 20388 },
+ { NODE_TYPE_TAGS, 9, 20459 }
};
CDirectoryNodeTvShowsOverview::CDirectoryNodeTvShowsOverview(const CStdString& strName, CDirectoryNode* pParent)
diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp
index 3a3d2c6308..47e9e0f0e3 100644
--- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp
+++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -180,7 +180,7 @@ JSONRPC_STATUS CVideoLibrary::GetTVShows(const CStdString &method, ITransportLay
}
CFileItemList items;
- if (!videodatabase.GetTvShowsNav(videoUrl.ToString(), items, genreID, year, -1, -1, -1, sorting))
+ if (!videodatabase.GetTvShowsNav(videoUrl.ToString(), items, genreID, year, -1, -1, -1, -1, sorting))
return InvalidParams;
bool additionalInfo = false;
diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp
index bfe702ead2..4e36cc4e0e 100644
--- a/xbmc/video/VideoDatabase.cpp
+++ b/xbmc/video/VideoDatabase.cpp
@@ -2939,15 +2939,23 @@ void CVideoDatabase::DeleteSet(int idSet)
}
}
-void CVideoDatabase::DeleteTag(int idTag, const std::string &mediaType)
+void CVideoDatabase::DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType)
{
try
{
if (m_pDB.get() == NULL || m_pDS.get() == NULL)
return;
+ std::string type;
+ if (mediaType == VIDEODB_CONTENT_MOVIES)
+ type = "movie";
+ else if (mediaType == VIDEODB_CONTENT_TVSHOWS)
+ type = "tvshow";
+ else
+ return;
+
CStdString strSQL;
- strSQL = PrepareSQL("DELETE FROM taglinks WHERE idTag = %i AND media_type = '%s'", idTag, mediaType.c_str());
+ strSQL = PrepareSQL("DELETE FROM taglinks WHERE idTag = %i AND media_type = '%s'", idTag, type.c_str());
m_pDS->exec(strSQL.c_str());
// check if the tag is used for another media type as well before deleting it completely
@@ -4550,6 +4558,8 @@ bool CVideoDatabase::GetTagsNav(const CStdString& strBaseDir, CFileItemList& ite
CStdString mediaType;
if (idContent == VIDEODB_CONTENT_MOVIES)
mediaType = "movie";
+ else if (idContent == VIDEODB_CONTENT_TVSHOWS)
+ mediaType = "tvshow";
else
return false;
@@ -5657,7 +5667,7 @@ bool CVideoDatabase::GetMoviesByWhere(const CStdString& strBaseDir, const Filter
}
bool CVideoDatabase::GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items,
- int idGenre /* = -1 */, int idYear /* = -1 */, int idActor /* = -1 */, int idDirector /* = -1 */, int idStudio /* = -1 */,
+ int idGenre /* = -1 */, int idYear /* = -1 */, int idActor /* = -1 */, int idDirector /* = -1 */, int idStudio /* = -1 */, int idTag /* = -1 */,
const SortDescription &sortDescription /* = SortDescription() */)
{
CVideoDbUrl videoUrl;
@@ -5674,6 +5684,8 @@ bool CVideoDatabase::GetTvShowsNav(const CStdString& strBaseDir, CFileItemList&
videoUrl.AddOption("year", idYear);
else if (idActor != -1)
videoUrl.AddOption("actorid", idActor);
+ else if (idTag != -1)
+ videoUrl.AddOption("tagid", idTag);
Filter filter;
return GetTvShowsByWhere(videoUrl.ToString(), filter, items, sortDescription);
@@ -8994,6 +9006,20 @@ bool CVideoDatabase::GetFilter(const CDbUrl &videoUrl, Filter &filter)
filter.AppendJoin(PrepareSQL("join actorlinktvshow on actorlinktvshow.idShow = tvshowview.idShow join actors on actors.idActor = actorlinktvshow.idActor"));
filter.AppendWhere(PrepareSQL("actors.strActor like '%s'", option->second.asString().c_str()));
}
+
+ option = options.find("tagid");
+ if (option != options.end())
+ {
+ filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = tvshowview.idShow AND taglinks.media_type = 'tvshow'"));
+ filter.AppendWhere(PrepareSQL("taglinks.idTag = %i", (int)option->second.asInteger()));
+ }
+
+ option = options.find("tag");
+ if (option != options.end())
+ {
+ filter.AppendJoin(PrepareSQL("join taglinks on taglinks.idMedia = tvshowview.idShow AND taglinks.media_type = 'tvshow' join tag on tag.idTag = taglinks.idTag"));
+ filter.AppendWhere(PrepareSQL("tag.strTag like '%s'", option->second.asString().c_str()));
+ }
}
else if (itemType == "seasons")
{
diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h
index 9fda573c96..134eb17f69 100644
--- a/xbmc/video/VideoDatabase.h
+++ b/xbmc/video/VideoDatabase.h
@@ -459,7 +459,7 @@ public:
void RemoveContentForPath(const CStdString& strPath,CGUIDialogProgress *progress = NULL);
void UpdateFanart(const CFileItem &item, VIDEODB_CONTENT_TYPE type);
void DeleteSet(int idSet);
- void DeleteTag(int idTag, const std::string &mediaType);
+ void DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType);
// per-file video settings
bool GetVideoSettings(const CStdString &strFilenameAndPath, CVideoSettings &settings);
@@ -589,7 +589,7 @@ public:
bool GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idArtist, const Filter &filter = Filter());
bool GetMoviesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idCountry=-1, int idSet=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());
- bool GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, const SortDescription &sortDescription = SortDescription());
+ bool GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());
bool GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& items, int idActor=-1, int idDirector=-1, int idGenre=-1, int idYear=-1, int idShow=-1);
bool GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription());
bool GetMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, const SortDescription &sortDescription = SortDescription());
diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp
index 7757d2370e..0abc7669f5 100644
--- a/xbmc/video/windows/GUIWindowVideoNav.cpp
+++ b/xbmc/video/windows/GUIWindowVideoNav.cpp
@@ -227,6 +227,8 @@ CStdString CGUIWindowVideoNav::GetQuickpathName(const CStdString& strPath) const
return "TvShowYears";
else if (strPath.Equals("videodb://2/4/"))
return "TvShowActors";
+ else if (strPath.Equals("videodb://2/9/"))
+ return "TvShowTags";
else if (strPath.Equals("videodb://2/"))
return "TvShows";
else if (strPath.Equals("videodb://3/1/"))
@@ -365,9 +367,11 @@ bool CGUIWindowVideoNav::GetDirectory(const CStdString &strDirectory, CFileItemL
LoadVideoInfo(items);
}
- if (items.GetPath() == "videodb://1/9/" && !items.Contains("newtag://movie"))
+ CVideoDbUrl videoUrl;
+ if (videoUrl.FromString(items.GetPath()) && items.GetContent() == "tags" &&
+ !items.Contains("newtag://" + videoUrl.GetType()))
{
- CFileItemPtr newTag(new CFileItem("newtag://movie", false));
+ CFileItemPtr newTag(new CFileItem("newtag://" + videoUrl.GetType(), false));
newTag->SetLabel(g_localizeStrings.Get(20462));
newTag->SetLabelPreformated(true);
newTag->SetSpecialSort(SortSpecialOnTop);
@@ -672,22 +676,22 @@ void CGUIWindowVideoNav::OnDeleteItem(CFileItemPtr pItem)
m_database.DeleteSet(params.GetSetId());
}
}
- else if (pItem->GetPath().Left(14).Equals("videodb://1/9/") &&
+ else if (m_vecItems->GetContent() == "tags" &&
pItem->GetPath().size() > 14 && pItem->m_bIsFolder)
{
CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
pDialog->SetHeading(432);
CStdString strLabel;
- strLabel.Format(g_localizeStrings.Get(433),pItem->GetLabel());
+ strLabel.Format(g_localizeStrings.Get(433), pItem->GetLabel());
pDialog->SetLine(1, strLabel);
- pDialog->SetLine(2, "");;
+ pDialog->SetLine(2, "");
pDialog->DoModal();
if (pDialog->IsConfirmed())
{
CVideoDatabaseDirectory dir;
CQueryParams params;
dir.GetQueryParams(pItem->GetPath(), params);
- m_database.DeleteTag(params.GetTagId(), "movie");
+ m_database.DeleteTag(params.GetTagId(), (VIDEODB_CONTENT_TYPE)params.GetContentType());
}
}
else if (m_vecItems->GetPath().Equals(CUtil::VideoPlaylistsLocation()) ||
@@ -966,13 +970,19 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt
buttons.Add(CONTEXT_BUTTON_DELETE, 646);
}
- if (item->GetPath().Left(14).Equals("videodb://1/9/") && item->GetPath().size() > 14 && item->m_bIsFolder) // tags
+ if (m_vecItems->GetContent() == "tags" && item->GetPath().size() > 14 && item->m_bIsFolder) // tags
{
- CStdString strLabelAdd; strLabelAdd.Format(g_localizeStrings.Get(20460), g_localizeStrings.Get(20342).c_str());
- CStdString strLabelRemove; strLabelRemove.Format(g_localizeStrings.Get(20461), g_localizeStrings.Get(20342).c_str());
- buttons.Add(CONTEXT_BUTTON_TAGS_ADD_ITEMS, strLabelAdd);
- buttons.Add(CONTEXT_BUTTON_TAGS_REMOVE_ITEMS, strLabelRemove);
- buttons.Add(CONTEXT_BUTTON_DELETE, 646);
+ CVideoDbUrl videoUrl;
+ if (videoUrl.FromString(item->GetPath()))
+ {
+ std::string mediaType = videoUrl.GetItemType();
+
+ CStdString strLabelAdd; strLabelAdd.Format(g_localizeStrings.Get(20460), GetLocalizedType(videoUrl.GetItemType()).c_str());
+ CStdString strLabelRemove; strLabelRemove.Format(g_localizeStrings.Get(20461), GetLocalizedType(videoUrl.GetItemType()).c_str());
+ buttons.Add(CONTEXT_BUTTON_TAGS_ADD_ITEMS, strLabelAdd);
+ buttons.Add(CONTEXT_BUTTON_TAGS_REMOVE_ITEMS, strLabelRemove);
+ buttons.Add(CONTEXT_BUTTON_DELETE, 646);
+ }
}
if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder)
@@ -1248,14 +1258,12 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
}
case CONTEXT_BUTTON_TAGS_ADD_ITEMS:
{
- if (!item->GetPath().Left(10).Equals("videodb://"))
+ CVideoDbUrl videoUrl;
+ if (!videoUrl.FromString(item->GetPath()))
return false;
- std::string mediaType;
- if (item->GetPath().Mid(9, 3).Equals("/1/"))
- mediaType = "movie";
- else
- return false;
+ std::string mediaType = videoUrl.GetItemType();
+ mediaType = mediaType.substr(0, mediaType.length() - 1);
CFileItemList items;
CStdString localizedType = GetLocalizedType(mediaType);
@@ -1282,14 +1290,12 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
}
case CONTEXT_BUTTON_TAGS_REMOVE_ITEMS:
{
- if (!item->GetPath().Left(10).Equals("videodb://"))
+ CVideoDbUrl videoUrl;
+ if (!videoUrl.FromString(item->GetPath()))
return false;
- std::string mediaType;
- if (item->GetPath().Mid(9, 3).Equals("/1/"))
- mediaType = "movie";
- else
- return false;
+ std::string mediaType = videoUrl.GetItemType();
+ mediaType = mediaType.substr(0, mediaType.length() - 1);
CFileItemList items;
CStdString localizedType = GetLocalizedType(mediaType);
@@ -1469,7 +1475,9 @@ bool CGUIWindowVideoNav::OnClick(int iItem)
if (!videodb.Open())
return true;
+ // get the media type and convert from plural to singular (by removing the trailing "s")
CStdString mediaType = item->GetPath().Mid(9);
+ mediaType = mediaType.Left(mediaType.size() - 1);
CStdString localizedType = GetLocalizedType(mediaType);
if (localizedType.empty())
return true;
@@ -1477,7 +1485,7 @@ bool CGUIWindowVideoNav::OnClick(int iItem)
if (!videodb.GetSingleValue("tag", "tag.idTag", videodb.PrepareSQL("tag.strTag = '%s' AND tag.idTag IN (SELECT taglinks.idTag FROM taglinks WHERE taglinks.media_type = '%s')", strTag.c_str(), mediaType.c_str())).empty())
{
CStdString strError; strError.Format(g_localizeStrings.Get(20463), strTag.c_str());
- CGUIDialogOK::ShowAndGetInput(20462, strError, "", "");
+ CGUIDialogOK::ShowAndGetInput(20462, "", strError, "");
return true;
}
@@ -1535,6 +1543,8 @@ CStdString CGUIWindowVideoNav::GetStartFolder(const CStdString &dir)
return "videodb://2/4/";
else if (dir.Equals("TvShowStudios"))
return "videodb://2/5/";
+ else if (dir.Equals("TvShowTags"))
+ return "videodb://2/9/";
else if (dir.Equals("TvShows"))
return "videodb://2/";
else if (dir.Equals("MusicVideoGenres"))
@@ -1635,23 +1645,38 @@ bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std:
if (!videodb.Open())
return false;
- CFileItemList listItems;
- bool result = false;
- if (idTag <= 0)
- result = videodb.GetMoviesNav("videodb://1/2/", listItems);
- else
+ MediaType mediaType;
+ std::string baseDir = "videodb://";
+ std::string idColumn;
+ if (type.compare("movie") == 0)
{
- if (showAll)
- {
- CVideoDatabase::Filter filter;
- filter.where = videodb.PrepareSQL("movieview.idMovie NOT IN (SELECT taglinks.idMedia FROM taglinks WHERE taglinks.idTag = %d AND taglinks.media_type = '%s')", idTag, type.c_str());
- result = videodb.GetMoviesByWhere("videodb://1/2/", filter, listItems);
- }
+ mediaType = MediaTypeMovie;
+ baseDir += "1";
+ idColumn = "idMovie";
+ }
+ else if (type.compare("tvshow") == 0)
+ {
+ mediaType = MediaTypeTvShow;
+ baseDir += "2";
+ idColumn = "idShow";
+ }
+
+ baseDir += "/2/";
+ CVideoDbUrl videoUrl;
+ if (!videoUrl.FromString(baseDir))
+ return false;
+
+ CVideoDatabase::Filter filter;
+ if (idTag > 0)
+ {
+ if (!showAll)
+ videoUrl.AddOption("tagid", idTag);
else
- result = videodb.GetMoviesNav("videodb://1/9/", listItems, -1, -1, -1, -1, -1, -1, -1, idTag);
+ filter.where = videodb.PrepareSQL("%sview.%s NOT IN (SELECT taglinks.idMedia FROM taglinks WHERE taglinks.idTag = %d AND taglinks.media_type = '%s')", type.c_str(), idColumn.c_str(), idTag, type.c_str());
}
- if (!result || listItems.Size() <= 0)
+ CFileItemList listItems;
+ if (!videodb.GetSortedVideos(mediaType, videoUrl.ToString(), SortDescription(), listItems, filter) || listItems.Size() <= 0)
return false;
CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
@@ -1673,13 +1698,13 @@ bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std:
CStdString CGUIWindowVideoNav::GetLocalizedType(const std::string &strType)
{
- if (strType == "movie")
+ if (strType == "movie" || strType == "movies")
return g_localizeStrings.Get(20342);
- else if (strType == "tvshow")
+ else if (strType == "tvshow" || strType == "tvshows")
return g_localizeStrings.Get(20343);
- else if (strType == "episode")
+ else if (strType == "episode" || strType == "episodes")
return g_localizeStrings.Get(20359);
- else if (strType == "musicvideo")
+ else if (strType == "musicvideo" || strType == "musicvideos")
return g_localizeStrings.Get(20391);
else
return "";