diff options
author | Alasdair Campbell <alcoheca@gmail.com> | 2012-10-08 16:36:26 +0100 |
---|---|---|
committer | Alasdair Campbell <alcoheca@gmail.com> | 2012-10-11 02:26:29 +0100 |
commit | 67fcd8c43c66579a956380aaf98ce0b6b7f026df (patch) | |
tree | b63c7843e92bec5ce4e6f301db0f662f436266a0 | |
parent | e2f1b7ae2ede609c590ca492b0196317080fc866 (diff) |
[UPnP] fix watched status for tvshows
-rw-r--r-- | xbmc/filesystem/UPnPDirectory.cpp | 20 | ||||
-rw-r--r-- | xbmc/network/upnp/UPnPInternal.cpp | 37 | ||||
-rw-r--r-- | xbmc/network/upnp/UPnPServer.cpp | 7 |
3 files changed, 48 insertions, 16 deletions
diff --git a/xbmc/filesystem/UPnPDirectory.cpp b/xbmc/filesystem/UPnPDirectory.cpp index 0cbe1e4813..6a9f9e424a 100644 --- a/xbmc/filesystem/UPnPDirectory.cpp +++ b/xbmc/filesystem/UPnPDirectory.cpp @@ -477,10 +477,24 @@ CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) break; } } - // HACK set the watched overlay, as this will not be set later due to + // set the watched overlay, as this will not be set later due to // content set on file item list - if (pItem->IsVideo()) - pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_playCount > 0); + if (pItem->HasVideoInfoTag()) { + int episodes = pItem->GetVideoInfoTag()->m_iEpisode; + int played = pItem->GetVideoInfoTag()->m_playCount; + const std::string& type = pItem->GetVideoInfoTag()->m_type; + bool watched(false); + if (type == "tvshow" || type == "season") { + pItem->SetProperty("totalepisodes", episodes); + pItem->SetProperty("numepisodes", episodes); + pItem->SetProperty("watchedepisodes", played); + pItem->SetProperty("unwatchedepisodes", episodes - played); + watched = (episodes && played == episodes); + } + else if (type == "episode") + watched = played; + pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, watched); + } items.Add(pItem); ++entry; diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp index 1b798f15dd..ea08774a32 100644 --- a/xbmc/network/upnp/UPnPInternal.cpp +++ b/xbmc/network/upnp/UPnPInternal.cpp @@ -235,27 +235,28 @@ PopulateObjectFromTag(CVideoInfoTag& tag, *file_path = tag.m_strFileNameAndPath; if (tag.m_iDbId != -1 ) { - if (!tag.m_artist.empty()) { + if (tag.m_type == "musicvideo") { object.m_ObjectClass.type = "object.item.videoItem.musicVideoClip"; object.m_Creator = StringUtils::Join(tag.m_artist, g_advancedSettings.m_videoItemSeparator); object.m_Title = tag.m_strTitle; object.m_ReferenceID = NPT_String::Format("videodb://3/2/%i", tag.m_iDbId); - } else if (!tag.m_strShowTitle.IsEmpty()) { + } else if (tag.m_type == "movie") { + object.m_ObjectClass.type = "object.item.videoItem.movie"; + object.m_Title = tag.m_strTitle; + object.m_Date = NPT_String::FromInteger(tag.m_iYear) + "-01-01"; + object.m_ReferenceID = NPT_String::Format("videodb://1/2/%i", tag.m_iDbId); + } else { object.m_ObjectClass.type = "object.item.videoItem.videoBroadcast"; object.m_Recorded.program_title = "S" + ("0" + NPT_String::FromInteger(tag.m_iSeason)).Right(2); object.m_Recorded.program_title += "E" + ("0" + NPT_String::FromInteger(tag.m_iEpisode)).Right(2); object.m_Recorded.program_title += " : " + tag.m_strTitle; object.m_Recorded.series_title = tag.m_strShowTitle; - object.m_Recorded.episode_number = tag.m_iSeason * 100 + tag.m_iEpisode; + int season = tag.m_iSeason > 1 ? tag.m_iSeason : 1; + object.m_Recorded.episode_number = season * 100 + tag.m_iEpisode; object.m_Title = object.m_Recorded.series_title + " - " + object.m_Recorded.program_title; object.m_Date = tag.m_firstAired.GetAsLocalizedDate(); if(tag.m_iSeason != -1) object.m_ReferenceID = NPT_String::Format("videodb://2/0/%i", tag.m_iDbId); - } else { - object.m_ObjectClass.type = "object.item.videoItem.movie"; - object.m_Title = tag.m_strTitle; - object.m_Date = NPT_String::FromInteger(tag.m_iYear) + "-01-01"; - object.m_ReferenceID = NPT_String::Format("videodb://1/2/%i", tag.m_iDbId); } } @@ -468,14 +469,12 @@ BuildObject(CFileItem& item, container->m_Creator = StringUtils::Join(tag.m_artist, g_advancedSettings.m_videoItemSeparator); container->m_Title = tag.m_strTitle; break; + case VIDEODATABASEDIRECTORY::NODE_TYPE_SEASONS: case VIDEODATABASEDIRECTORY::NODE_TYPE_TITLE_TVSHOWS: container->m_ObjectClass.type += ".album.videoAlbum"; - container->m_Recorded.program_title = "S" + ("0" + NPT_String::FromInteger(tag.m_iSeason)).Right(2); - container->m_Recorded.program_title += "E" + ("0" + NPT_String::FromInteger(tag.m_iEpisode)).Right(2); - container->m_Recorded.program_title += " : " + tag.m_strTitle; container->m_Recorded.series_title = tag.m_strShowTitle; - container->m_Recorded.episode_number = tag.m_iSeason * 100 + tag.m_iEpisode; - container->m_Title = container->m_Recorded.series_title + " - " + container->m_Recorded.program_title; + container->m_Recorded.episode_number = tag.m_iEpisode; + container->m_MiscInfo.play_count = tag.m_playCount; container->m_Title = tag.m_strTitle; if(!tag.m_firstAired.IsValid() && tag.m_iYear) container->m_Date = NPT_String::FromInteger(tag.m_iYear) + "-01-01"; @@ -623,6 +622,7 @@ PopulateTagFromObject(CVideoInfoTag& tag, if(!object.m_Recorded.program_title.IsEmpty()) { + tag.m_type = "episode"; int episode; int season; int title = object.m_Recorded.program_title.Find(" : "); @@ -637,8 +637,19 @@ PopulateTagFromObject(CVideoInfoTag& tag, } tag.m_firstAired = date; } + else if (!object.m_Recorded.series_title.IsEmpty()) { + tag.m_type= "season"; + tag.m_strTitle = object.m_Title; // because could be TV show Title, or Season 1 etc + tag.m_iSeason = object.m_Recorded.episode_number / 100; + tag.m_iEpisode = object.m_Recorded.episode_number % 100; + tag.m_premiered = date; + } + else if(object.m_ObjectClass.type == "object.item.videoItem.musicVideoClip") { + tag.m_type = "musicvideo"; + } else { + tag.m_type = "movie"; tag.m_strTitle = object.m_Title; tag.m_premiered = date; } diff --git a/xbmc/network/upnp/UPnPServer.cpp b/xbmc/network/upnp/UPnPServer.cpp index ebd3ce9ffa..ada9d7fd66 100644 --- a/xbmc/network/upnp/UPnPServer.cpp +++ b/xbmc/network/upnp/UPnPServer.cpp @@ -151,6 +151,13 @@ CUPnPServer::Build(CFileItemPtr item, db.GetTvShowInfo((const char*)path, *item->GetVideoInfoTag(), params.GetTvShowId()); } + if (item->GetVideoInfoTag()->m_type == "tvshow" || item->GetVideoInfoTag()->m_type == "season") { + // for tvshows and seasons, iEpisode and playCount are + // invalid + item->GetVideoInfoTag()->m_iEpisode = item->GetProperty("totalepisodes").asInteger(); + item->GetVideoInfoTag()->m_playCount = item->GetProperty("watchedepisodes").asInteger(); + } + // try to grab title from tag if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.IsEmpty()) { item->SetLabel(item->GetVideoInfoTag()->m_strTitle); |