bool SaveFileState(const CFileItem& item, const CBookmark& bookmark, const bool updatePlayCount) { std::string path = item.GetProperty("original_listitem_url").asString(); if (!item.HasVideoInfoTag() || path.empty()) { return false; } NPT_String curr_value; NPT_String new_value; if (item.GetVideoInfoTag()->m_resumePoint.timeInSeconds != bookmark.timeInSeconds) { CLog::Log(LOGDEBUG, "UPNP: Updating resume point for item %s", path.c_str()); long time = (long)bookmark.timeInSeconds; if (time < 0) time = 0; curr_value.Append(NPT_String::Format("<upnp:lastPlaybackPosition>%ld</upnp:lastPlaybackPosition>", (long)item.GetVideoInfoTag()->m_resumePoint.timeInSeconds)); new_value.Append(NPT_String::Format("<upnp:lastPlaybackPosition>%ld</upnp:lastPlaybackPosition>", time)); } if (updatePlayCount) { CLog::Log(LOGDEBUG, "UPNP: Marking video item %s as watched", path.c_str()); if (!curr_value.IsEmpty()) curr_value.Append(","); if (!new_value.IsEmpty()) new_value.Append(","); curr_value.Append("<upnp:playCount>0</upnp:playCount>"); new_value.Append("<upnp:playCount>1</upnp:playCount>"); } return InvokeUpdateObject(path.c_str(), (const char*)curr_value, (const char*)new_value); }
void CVideoThumbLoader::DetectAndAddMissingItemData(CFileItem &item) { if (item.m_bIsFolder) return; std::string stereoMode; // detect stereomode for videos if (item.HasVideoInfoTag()) stereoMode = item.GetVideoInfoTag()->m_streamDetails.GetStereoMode(); if (stereoMode.empty()) { std::string path = item.GetPath(); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->GetPath(); // check for custom stereomode setting in video settings CVideoSettings itemVideoSettings; m_videoDatabase->Open(); if (m_videoDatabase->GetVideoSettings(path, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) stereoMode = CStereoscopicsManager::Get().ConvertGuiStereoModeToString( (RENDER_STEREO_MODE) itemVideoSettings.m_StereoMode ); m_videoDatabase->Close(); // still empty, try grabbing from filename // TODO: in case of too many false positives due to using the full path, extract the filename only using string utils if (stereoMode.empty()) stereoMode = CStereoscopicsManager::Get().DetectStereoModeByString( path ); } if (!stereoMode.empty()) item.SetProperty("stereomode", CStereoscopicsManager::Get().NormalizeStereoMode(stereoMode)); }
bool CVideoThumbLoader::FillThumb(CFileItem &item) { if (item.HasArt("thumb")) return true; std::string thumb = GetCachedImage(item, "thumb"); if (thumb.empty()) { thumb = GetLocalArt(item, "thumb"); if (!thumb.empty()) SetCachedImage(item, "thumb", thumb); } if (!thumb.empty()) item.SetArt("thumb", thumb); else { // If nothing was found, try embedded art if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->m_coverArt.empty()) { for (auto& it : item.GetVideoInfoTag()->m_coverArt) { if (it.m_type == "thumb") { thumb = CTextureUtils::GetWrappedImageURL(item.GetPath(), "video_" + it.m_type); item.SetArt(it.m_type, thumb); } } } } return !thumb.empty(); }
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt) { // prompt for choice CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!dialog || !videoItem.HasVideoInfoTag()) return ""; CFileItemList items; dialog->SetHeading(13511); dialog->Reset(); dialog->SetUseDetails(true); dialog->EnableButton(true, 13516); CVideoDatabase db; db.Open(); vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type); // add in any stored art for this item that is non-empty. db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt); for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i) { if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end()) artTypes.push_back(i->first); } // add any art types that exist for other media items of the same type vector<string> dbArtTypes; db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes); for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++) { if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end()) artTypes.push_back(*it); } for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i) { string type = *i; CFileItemPtr item(new CFileItem(type, "false")); item->SetLabel(type); if (videoItem.HasArt(type)) item->SetArt("thumb", videoItem.GetArt(type)); items.Add(item); } dialog->SetItems(&items); dialog->DoModal(); if (dialog->IsButtonPressed()) { // Get the new artwork name CStdString strArtworkName; if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false)) return ""; return strArtworkName; } return dialog->GetSelectedItem()->GetLabel(); }
CStdString CEdenVideoArtUpdater::GetCachedEpisodeThumb(const CFileItem &item) { // get the locally cached thumb CStdString strCRC = StringUtils::Format("%sepisode%i", item.GetVideoInfoTag()->m_strFileNameAndPath.c_str(), item.GetVideoInfoTag()->m_iEpisode); return GetThumb(strCRC, CProfilesManager::Get().GetVideoThumbFolder(), true); }
void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str()); if (m_bStreamDetails && !item.HasVideoInfoTag()) return; if (m_tAudio >= 0 && (m_tAudio > 0) != item.IsAudio()) return; if (m_tVideo >= 0 && (m_tVideo > 0) != item.IsVideo()) return; if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != item.IsInternetStream()) return; if (m_tDVD >= 0 && (m_tDVD > 0) != item.IsDVD()) return; if (m_tDVDFile >= 0 && (m_tDVDFile > 0) != item.IsDVDFile()) return; if (m_tDVDImage >= 0 && (m_tDVDImage > 0) != item.IsDVDImage()) return; CRegExp regExp; if (m_bStreamDetails) { if (!item.GetVideoInfoTag()->HasStreamDetails()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: cannot check rule: %s, no StreamDetails", m_name.c_str()); return; } CStreamDetails streamDetails = item.GetVideoInfoTag()->m_streamDetails; if (CompileRegExp(m_audioCodec, regExp) && !MatchesRegExp(streamDetails.GetAudioCodec(), regExp)) return; if (CompileRegExp(m_videoCodec, regExp) && !MatchesRegExp(streamDetails.GetVideoCodec(), regExp)) return; if (CompileRegExp(m_videoResolution, regExp) && !MatchesRegExp(CStreamDetails::VideoDimsToResolutionDescription(streamDetails.GetVideoWidth(), streamDetails.GetVideoHeight()), regExp)) return; if (CompileRegExp(m_videoAspect, regExp) && !MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return; } CURL url(item.GetPath()); if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return; if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return; if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return; if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return; CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str()); for (unsigned int i = 0; i < vecSubRules.size(); i++) vecSubRules[i]->GetPlayers(item, vecCores); PLAYERCOREID playerCoreId = GetPlayerCore(); if (playerCoreId != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s (%d) for rule: %s", m_playerName.c_str(), playerCoreId, m_name.c_str()); vecCores.push_back(GetPlayerCore()); } }
CStdString CEdenVideoArtUpdater::GetCachedFanart(const CFileItem &item) { if (!item.GetVideoInfoTag()->m_artist.empty()) return GetThumb(StringUtils::Join(item.GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), URIUtils::AddFileToFolder(CProfilesManager::Get().GetThumbnailsFolder(), "Music/Fanart/"), false); CStdString path = item.GetVideoInfoTag()->GetPath(); if (path.empty()) return ""; return GetThumb(path, URIUtils::AddFileToFolder(CProfilesManager::Get().GetVideoThumbFolder(), "Fanart/"), false); }
void CVideoThumbLoader::DetectAndAddMissingItemData(CFileItem &item) { if (item.m_bIsFolder) return; if (item.HasVideoInfoTag()) { CStreamDetails& details = item.GetVideoInfoTag()->m_streamDetails; // add audio language properties for (int i = 1; i <= details.GetAudioStreamCount(); i++) { std::string index = StringUtils::Format("%i", i); item.SetProperty("AudioChannels." + index, details.GetAudioChannels(i)); item.SetProperty("AudioCodec." + index, details.GetAudioCodec(i).c_str()); item.SetProperty("AudioLanguage." + index, details.GetAudioLanguage(i).c_str()); } // add subtitle language properties for (int i = 1; i <= details.GetSubtitleStreamCount(); i++) { std::string index = StringUtils::Format("%i", i); item.SetProperty("SubtitleLanguage." + index, details.GetSubtitleLanguage(i).c_str()); } } const CStereoscopicsManager &stereoscopicsManager = CServiceBroker::GetGUI()->GetStereoscopicsManager(); std::string stereoMode; // detect stereomode for videos if (item.HasVideoInfoTag()) stereoMode = item.GetVideoInfoTag()->m_streamDetails.GetStereoMode(); if (stereoMode.empty()) { std::string path = item.GetPath(); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->GetPath(); // check for custom stereomode setting in video settings CVideoSettings itemVideoSettings; m_videoDatabase->Open(); if (m_videoDatabase->GetVideoSettings(item, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) { stereoMode = CStereoscopicsManager::ConvertGuiStereoModeToString(static_cast<RENDER_STEREO_MODE>(itemVideoSettings.m_StereoMode)); } m_videoDatabase->Close(); // still empty, try grabbing from filename //! @todo in case of too many false positives due to using the full path, extract the filename only using string utils if (stereoMode.empty()) stereoMode = stereoscopicsManager.DetectStereoModeByString(path); } if (!stereoMode.empty()) item.SetProperty("stereomode", CStereoscopicsManager::NormalizeStereoMode(stereoMode)); }
std::string CMime::GetMimeType(const CFileItem &item) { std::string path = item.GetPath(); if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->GetPath().empty()) path = item.GetVideoInfoTag()->GetPath(); else if (item.HasMusicInfoTag() && !item.GetMusicInfoTag()->GetURL().empty()) path = item.GetMusicInfoTag()->GetURL(); return GetMimeType(URIUtils::GetExtension(path)); }
void CXBMCApp::onNewIntent(CJNIIntent intent) { std::string action = intent.getAction(); CLog::Log(LOGDEBUG, "CXBMCApp::onNewIntent - Got intent. Action: %s", action.c_str()); std::string targetFile = GetFilenameFromIntent(intent); if (!targetFile.empty() && (action == "android.intent.action.VIEW" || action == "android.intent.action.GET_CONTENT")) { CLog::Log(LOGDEBUG, "-- targetFile: %s", targetFile.c_str()); CURL targeturl(targetFile); std::string value; if (action == "android.intent.action.GET_CONTENT" || (targeturl.GetOption("showinfo", value) && value == "true")) { if (targeturl.IsProtocol("videodb") || (targeturl.IsProtocol("special") && targetFile.find("playlists/video") != std::string::npos) || (targeturl.IsProtocol("special") && targetFile.find("playlists/mixed") != std::string::npos) ) { std::vector<std::string> params; params.push_back(targeturl.Get()); params.push_back("return"); CApplicationMessenger::GetInstance().PostMsg(TMSG_GUI_ACTIVATE_WINDOW, WINDOW_VIDEO_NAV, 0, nullptr, "", params); } else if (targeturl.IsProtocol("musicdb") || (targeturl.IsProtocol("special") && targetFile.find("playlists/music") != std::string::npos)) { std::vector<std::string> params; params.push_back(targeturl.Get()); params.push_back("return"); CApplicationMessenger::GetInstance().PostMsg(TMSG_GUI_ACTIVATE_WINDOW, WINDOW_MUSIC_NAV, 0, nullptr, "", params); } } else { CFileItem* item = new CFileItem(targetFile, false); if (item->IsVideoDb()) { *(item->GetVideoInfoTag()) = XFILE::CVideoDatabaseFile::GetVideoTag(CURL(item->GetPath())); item->SetPath(item->GetVideoInfoTag()->m_strFileNameAndPath); } CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(item)); } } else if (action == ACTION_XBMC_RESUME) { if (m_playback_state != PLAYBACK_STATE_STOPPED) { if (m_playback_state & PLAYBACK_STATE_VIDEO) RequestVisibleBehind(true); if (!(m_playback_state & PLAYBACK_STATE_PLAYING)) CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(ACTION_PAUSE))); } } }
void CGUIWindowVideoInfo::PlayTrailer() { CFileItem item; item.m_strPath = m_movieItem->GetVideoInfoTag()->m_strTrailer; *item.GetVideoInfoTag() = *m_movieItem->GetVideoInfoTag(); item.GetVideoInfoTag()->m_strTitle.Format("%s (%s)",m_movieItem->GetVideoInfoTag()->m_strTitle.c_str(),g_localizeStrings.Get(20410)); item.SetThumbnailImage(m_movieItem->GetThumbnailImage()); // Close the dialog. Close(true); g_application.getApplicationMessenger().PlayFile(item); }
bool CGUIDialogPlayEject::ShowAndGetInput(const CFileItem & item, unsigned int uiAutoCloseTime /* = 0 */) { // Make sure we're actually dealing with a Disc Stub if (!item.IsDiscStub()) return false; // Create the dialog CGUIDialogPlayEject * pDialog = (CGUIDialogPlayEject *)g_windowManager. GetWindow(WINDOW_DIALOG_PLAY_EJECT); if (!pDialog) return false; // Figure out Line 1 of the dialog CStdString strLine1; if (item.GetVideoInfoTag()) { strLine1 = item.GetVideoInfoTag()->m_strTitle; } else { strLine1 = URIUtils::GetFileName(item.GetPath()); URIUtils::RemoveExtension(strLine1); } // Figure out Line 2 of the dialog CStdString strLine2; CXBMCTinyXML discStubXML; if (discStubXML.LoadFile(item.GetPath())) { TiXmlElement * pRootElement = discStubXML.RootElement(); if (!pRootElement || strcmpi(pRootElement->Value(), "discstub") != 0) CLog::Log(LOGERROR, "Error loading %s, no <discstub> node", item.GetPath().c_str()); else XMLUtils::GetString(pRootElement, "message", strLine2); } // Setup dialog parameters pDialog->SetHeading(219); pDialog->SetLine(0, 429); pDialog->SetLine(1, strLine1); pDialog->SetLine(2, strLine2); pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208); pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391); if (uiAutoCloseTime) pDialog->SetAutoClose(uiAutoCloseTime); // Display the dialog pDialog->DoModal(); return pDialog->IsConfirmed(); }
CStdString CEdenVideoArtUpdater::GetCachedVideoThumb(const CFileItem &item) { if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.empty()) return GetThumb(item.GetVideoInfoTag()->m_strPath, CProfilesManager::Get().GetVideoThumbFolder(), true); else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.empty()) { CStdString path = item.GetVideoInfoTag()->m_strFileNameAndPath; if (URIUtils::IsStack(path)) path = CStackDirectory::GetFirstStackedFile(path); return GetThumb(path, CProfilesManager::Get().GetVideoThumbFolder(), true); } return GetThumb(item.GetPath(), CProfilesManager::Get().GetVideoThumbFolder(), true); }
CStdString CThumbnailCache::GetVideoThumb(const CFileItem &item) { if (item.IsStack()) return GetThumb(CStackDirectory::GetFirstStackedFile(item.GetPath()), g_settings.GetVideoThumbFolder(), true); else if (item.IsVideoDb() && item.HasVideoInfoTag()) { if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strPath, g_settings.GetVideoThumbFolder(), true); else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strFileNameAndPath, g_settings.GetVideoThumbFolder(), true); } return GetThumb(item.GetPath(), g_settings.GetVideoThumbFolder(), true); }
/// \brief Make the actual search for the OnSearch function. /// \param strSearch The search string /// \param items Items Found void CGUIWindowVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items) { VECMOVIES movies; m_database.GetMoviesByActor(strSearch, movies); for (int i = 0; i < (int)movies.size(); ++i) { CStdString strItem; strItem.Format("[%s] %s (%i)", g_localizeStrings.Get(20338), movies[i].m_strTitle, movies[i].m_iYear); // Movie CFileItem *pItem = new CFileItem(strItem); *pItem->GetVideoInfoTag() = movies[i]; pItem->m_strPath = movies[i].m_strFileNameAndPath; items.Add(pItem); } movies.clear(); m_database.GetTvShowsByActor(strSearch, movies); for (int i = 0; i < (int)movies.size(); ++i) { CStdString strItem; strItem.Format("[%s] %s", g_localizeStrings.Get(20364), movies[i].m_strTitle); // Movie CFileItem *pItem = new CFileItem(strItem); *pItem->GetVideoInfoTag() = movies[i]; pItem->m_strPath.Format("videodb://1/%u",movies[i].m_iDbId); items.Add(pItem); } movies.clear(); m_database.GetEpisodesByActor(strSearch, movies); for (int i = 0; i < (int)movies.size(); ++i) { CStdString strItem; strItem.Format("[%s] %s", g_localizeStrings.Get(20359), movies[i].m_strTitle); // Movie CFileItem *pItem = new CFileItem(strItem); *pItem->GetVideoInfoTag() = movies[i]; pItem->m_strPath = movies[i].m_strFileNameAndPath; items.Add(pItem); } CFileItemList mvids; m_database.GetMusicVideosByArtist(strSearch, mvids); for (int i = 0; i < (int)mvids.Size(); ++i) { CStdString strItem; strItem.Format("[%s] %s", g_localizeStrings.Get(20391), mvids[i]->GetVideoInfoTag()->m_strTitle); // Movie CFileItem *pItem = new CFileItem(strItem); *pItem->GetVideoInfoTag() = *mvids[i]->GetVideoInfoTag(); pItem->m_strPath = mvids[i]->GetVideoInfoTag()->m_strFileNameAndPath; items.Add(pItem); } }
CStdString CThumbnailCache::GetEpisodeThumb(const CFileItem &item) { if (!item.HasVideoInfoTag()) return CStdString(); return GetEpisodeThumb(item.GetVideoInfoTag()); }
std::string CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std::string &contextWindow) { std::string execute; if (item.m_bIsFolder && (g_advancedSettings.m_playlistAsFolders || !(item.IsSmartPlayList() || item.IsPlayList()))) { if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } /* TODO:STRING_CLEANUP */ else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { if (item.IsVideoDb() && item.HasVideoInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetVideoInfoTag()->m_strFileNameAndPath).c_str()); else if (item.IsMusicDb() && item.HasMusicInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetMusicInfoTag()->GetURL()).c_str()); else if (item.IsPicture()) execute = StringUtils::Format("ShowPicture(%s)", StringUtils::Paramify(item.GetPath()).c_str()); else execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetPath()).c_str()); } return execute; }
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item) { /* if asked to resume somewhere, we should not show anything */ if (item.m_lStartOffset || (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iBookmarkId > 0)) return true; if (CSettings::GetInstance().GetInt(CSettings::SETTING_DISC_PLAYBACK) != BD_PLAYBACK_SIMPLE_MENU) return true; std::string path; if (item.IsVideoDb()) path = item.GetVideoInfoTag()->m_strFileNameAndPath; else path = item.GetPath(); if (item.IsBDFile()) { std::string root = URIUtils::GetParentPath(path); URIUtils::RemoveSlashAtEnd(root); if (URIUtils::GetFileName(root) == "BDMV") { CURL url("bluray://"); url.SetHostName(URIUtils::GetParentPath(root)); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } if (item.IsDiscImage()) { CURL url2("udf://"); url2.SetHostName(item.GetPath()); url2.SetFileName("BDMV/index.bdmv"); if (XFILE::CFile::Exists(url2.Get())) { url2.SetFileName(""); CURL url("bluray://"); url.SetHostName(url2.Get()); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } return true; }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.empty()) { std::map<std::string, std::string> artwork; m_videoDatabase->Open(); if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) SetArt(item, artwork); else if (tag.m_type == "actor" && !tag.m_artist.empty()) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idArtist = database.GetArtistByName(item.GetLabel()); if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork)) item.SetArt(artwork); } else if (tag.m_type == MediaTypeAlbum) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist); if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork)) item.SetArt(artwork); } if (tag.m_type == MediaTypeEpisode || tag.m_type == MediaTypeSeason) { // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("tvshow.fanart") && tag.m_iIdShow >= 0) { const ArtMap& artmap = GetArtFromCache(MediaTypeTvShow, tag.m_iIdShow); if (!artmap.empty()) { item.AppendArt(artmap, MediaTypeTvShow); item.SetArtFallback("fanart", "tvshow.fanart"); item.SetArtFallback("tvshow.thumb", "tvshow.poster"); } } if (tag.m_type == MediaTypeEpisode && !item.HasArt("season.poster") && tag.m_iSeason > -1) { const ArtMap& artmap = GetArtFromCache(MediaTypeSeason, tag.m_iIdSeason); if (!artmap.empty()) item.AppendArt(artmap, MediaTypeSeason); } } else if (tag.m_type == MediaTypeMovie && tag.m_set.id >= 0 && !item.HasArt("set.fanart")) { const ArtMap& artmap = GetArtFromCache(MediaTypeVideoCollection, tag.m_set.id); if (!artmap.empty()) item.AppendArt(artmap, MediaTypeVideoCollection); } m_videoDatabase->Close(); } return !item.GetArt().empty(); }
CStdString CVideoThumbLoader::GetEmbeddedThumbURL(const CFileItem &item) { CStdString path(item.GetPath()); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->m_strFileNameAndPath; if (URIUtils::IsStack(path)) path = CStackDirectory::GetFirstStackedFile(path); return CTextureCache::GetWrappedImageURL(path, "video"); }
void CGUIDialogVideoInfo::PlayTrailer() { CFileItem item; item.SetPath(m_movieItem->GetVideoInfoTag()->m_strTrailer); *item.GetVideoInfoTag() = *m_movieItem->GetVideoInfoTag(); item.GetVideoInfoTag()->m_streamDetails.Reset(); item.GetVideoInfoTag()->m_strTitle.Format("%s (%s)",m_movieItem->GetVideoInfoTag()->m_strTitle.c_str(),g_localizeStrings.Get(20410)); item.SetThumbnailImage(m_movieItem->GetThumbnailImage()); item.GetVideoInfoTag()->m_iDbId = -1; item.GetVideoInfoTag()->m_iFileId = -1; // Close the dialog. Close(true); if (item.IsPlayList()) g_application.getApplicationMessenger().MediaPlay(item); else g_application.getApplicationMessenger().PlayFile(item); }
bool CMarkUnWatched::IsVisible(const CFileItem& item) const { if (!item.HasVideoInfoTag()) return false; if (item.IsPVR()) return false; // pvr has its own implementation for this if (item.m_bIsFolder) //Only allow db content to be updated recursively return item.IsVideoDb(); return item.GetVideoInfoTag()->m_playCount > 0; }
static void SetupRarOptions(CFileItem& item, const CStdString& path) { CStdString path2(path); if (item.IsVideoDb() && item.HasVideoInfoTag()) path2 = item.GetVideoInfoTag()->m_strFileNameAndPath; CURL url(path2); CStdString opts = url.GetOptions(); if (opts.Find("flags") > -1) return; if (opts.size()) opts += "&flags=8"; else opts = "?flags=8"; url.SetOptions(opts); if (item.IsVideoDb() && item.HasVideoInfoTag()) item.GetVideoInfoTag()->m_strFileNameAndPath = url.Get(); else item.SetPath(url.Get()); g_directoryCache.ClearDirectory(url.GetWithoutFilename()); }
CStdString CThumbnailCache::GetFanart(const CFileItem &item) { // get the locally cached thumb if (item.IsVideoDb()) { if (!item.HasVideoInfoTag()) return ""; if (!item.GetVideoInfoTag()->m_strArtist.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strArtist,g_settings.GetMusicFanartFolder()); if (!item.m_bIsFolder && !item.GetVideoInfoTag()->m_strShowTitle.IsEmpty()) { CVideoDatabase database; database.Open(); int iShowId = database.GetTvShowId(item.GetVideoInfoTag()->m_strPath); CStdString showPath; database.GetFilePathById(iShowId,showPath,VIDEODB_CONTENT_TVSHOWS); return GetThumb(showPath,g_settings.GetVideoFanartFolder()); } return GetThumb(item.m_bIsFolder ? item.GetVideoInfoTag()->m_strPath : item.GetVideoInfoTag()->m_strFileNameAndPath,g_settings.GetVideoFanartFolder()); } if (item.HasMusicInfoTag()) return GetThumb(item.GetMusicInfoTag()->GetArtist(),g_settings.GetMusicFanartFolder()); return GetThumb(item.m_strPath,g_settings.GetVideoFanartFolder()); }
string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt) { // prompt for choice CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!dialog || !videoItem.HasVideoInfoTag()) return ""; CFileItemList items; dialog->SetHeading(13511); dialog->Reset(); dialog->SetUseDetails(true); CVideoDatabase db; db.Open(); vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type); // add in any stored art for this item that is non-empty. db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt); for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i) { if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end()) artTypes.push_back(i->first); } for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i) { string type = *i; CFileItemPtr item(new CFileItem(type, "false")); item->SetLabel(type); if (videoItem.HasArt(type)) item->SetArt("thumb", videoItem.GetArt(type)); items.Add(item); } dialog->SetItems(&items); dialog->DoModal(); return dialog->GetSelectedItem()->GetLabel(); }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.IsEmpty()) { map<string, string> artwork; m_database->Open(); if (m_database->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) item.SetArt(artwork); else if (tag.m_type == "artist") { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idArtist = database.GetArtistByName(item.GetLabel()); if (database.GetArtForItem(idArtist, "artist", artwork)) item.SetArt(artwork); } else if (tag.m_type == "album") { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist); if (database.GetArtForItem(idAlbum, "album", artwork)) item.SetArt(artwork); } // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("fanart") && tag.m_iIdShow >= 0) { ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow); if (i != m_showArt.end()) item.AppendArt(i->second); else { map<string, string> showArt, cacheArt; if (m_database->GetArtForItem(tag.m_iIdShow, "tvshow", showArt)) { for (CGUIListItem::ArtMap::iterator i = showArt.begin(); i != showArt.end(); ++i) { if (i->first == "fanart") cacheArt.insert(*i); else cacheArt.insert(make_pair("tvshow." + i->first, i->second)); } item.AppendArt(cacheArt); } m_showArt.insert(make_pair(tag.m_iIdShow, cacheArt)); } } m_database->Close(); } return !item.GetArt().empty(); }
CThumbExtractor::CThumbExtractor(const CFileItem& item, const CStdString& listpath, bool thumb, const CStdString& target) { m_listpath = listpath; m_target = target; m_thumb = thumb; m_item = item; if (item.IsVideoDb() && item.HasVideoInfoTag()) m_item.SetPath(item.GetVideoInfoTag()->m_strFileNameAndPath); if (m_item.IsStack()) m_item.SetPath(CStackDirectory::GetFirstStackedFile(m_item.GetPath())); }
void CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item) { if (!item.HasVideoInfoTag()) return; CStdString itemDir = item.GetVideoInfoTag()->m_basePath; //season if (itemDir.IsEmpty()) itemDir = item.GetVideoInfoTag()->GetPath(); CFileItem itemTmp(itemDir, false); if (itemTmp.IsVideo()) itemDir = URIUtils::GetParentPath(itemDir); if (!itemDir.IsEmpty() && CDirectory::Exists(itemDir)) { CMediaSource itemSource; itemSource.strName = g_localizeStrings.Get(36041); itemSource.strPath = itemDir; sources.push_back(itemSource); } }
void CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper) { if (!scraper || scraper->Content() == CONTENT_NONE) { m_database.Open(); // since we can be called from the music library without being inited if (fileItem.IsVideoDb()) scraper = m_database.GetScraperForPath(fileItem.GetVideoInfoTag()->m_strPath); else { std::string strPath,strFile; URIUtils::Split(fileItem.GetPath(),strPath,strFile); scraper = m_database.GetScraperForPath(strPath); } m_database.Close(); } CGUIWindowVideoBase::OnItemInfo(fileItem, scraper); }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.empty()) { map<string, string> artwork; m_videoDatabase->Open(); if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) SetArt(item, artwork); else if (tag.m_type == MediaTypeArtist) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idArtist = database.GetArtistByName(item.GetLabel()); if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork)) item.SetArt(artwork); } else if (tag.m_type == MediaTypeAlbum) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist); if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork)) item.SetArt(artwork); } // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("fanart") && tag.m_iIdShow >= 0) { ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow); if (i == m_showArt.end()) { map<string, string> showArt; m_videoDatabase->GetArtForItem(tag.m_iIdShow, MediaTypeTvShow, showArt); i = m_showArt.insert(make_pair(tag.m_iIdShow, showArt)).first; } if (i != m_showArt.end()) { item.AppendArt(i->second, "tvshow"); item.SetArtFallback("fanart", "tvshow.fanart"); item.SetArtFallback("tvshow.thumb", "tvshow.poster"); } } m_videoDatabase->Close(); } return !item.GetArt().empty(); }