bool CGUIWindowEventLog::GetDirectory(const std::string &strDirectory, CFileItemList &items) { bool result = CGUIMediaWindow::GetDirectory(strDirectory, items); EventLevel currentLevel = CViewStateSettings::GetInstance().GetEventLevel(); bool showHigherLevels = CViewStateSettings::GetInstance().ShowHigherEventLevels(); CFileItemList filteredItems(items.GetPath()); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items.Get(i); if (item->IsParentFolder()) { filteredItems.Add(item); continue; } if (!item->HasProperty(PROPERTY_EVENT_LEVEL)) continue; EventLevel level = CEventLog::GetInstance().EventLevelFromString(item->GetProperty(PROPERTY_EVENT_LEVEL).asString()); if (level == currentLevel || (level > currentLevel && showHigherLevels)) filteredItems.Add(item); } items.ClearItems(); items.Append(filteredItems); return result; }
void CGUIWindowBoxeeMediaMain::LoadMediaItems() { Cleanup(); LoadMediaItems(m_listMediaItems); LoadAppItems(m_listApps); m_listMediaItemsSmall.Append(m_listMediaItems); m_listAppsSmall.Append(m_listApps); CLog::Log(LOGDEBUG,"%s - loaded %d media items and %d applications", __FUNCTION__, m_listMediaItems.Size(), m_listApps.Size()); int i; for (i=0; i<m_listMediaItems.Size(); i++) { CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST, 0, 0, m_listMediaItems[i]); OnMessage(winmsg); CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST_SMALL, 0, 0, m_listMediaItemsSmall[i]); OnMessage(winmsg2); } for (i=0; i<m_listApps.Size(); i++) { CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST, 0, 0, m_listApps[i]); OnMessage(winmsg); CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST_SMALL, 0, 0, m_listAppsSmall[i]); OnMessage(winmsg2); } // Load thumbnails for the items CLog::Log(LOGDEBUG,"Loading thumbnail for %d items", m_listMediaItems.Size()); m_listMediaItems.FillInDefaultIcons(); m_Loader = GetLoader(); CFileItemList *pList = new CFileItemList; pList->Append(m_listMediaItems); pList->Append(m_listApps); m_Loader->SetObserver(this); m_Loader->Load(*pList); }
// advanced shares enumeration function // if this function is failed, simple 'localGetNetworkResources()' can be used static bool localGetShares(const std::wstring& serverNameToScan, const std::string& urlPrefixForItems, CFileItemList& items) { assert(serverNameToScan.compare(0, 2, L"\\\\", 2) == 0); // 'serverNameToScan' must be in form '\\ServerName' assert(serverNameToScan.length() > 2); assert(urlPrefixForItems.compare(0, 6, "smb://", 6) == 0); // 'urlPrefixForItems' must be in form 'smb://[user[:pass]@]ServerName/' assert(urlPrefixForItems.length() > 7); assert(urlPrefixForItems.back() == '/'); CFileItemList locItems; // store items locally until last one is successfully loaded NET_API_STATUS enumResult; DWORD hEnumResume = 0; bool errorFlag = false; do { SHARE_INFO_1* shareInfos = NULL; DWORD count, totalCount; enumResult = NetShareEnum((LPWSTR)serverNameToScan.c_str(), 1, (LPBYTE*)&shareInfos, MAX_PREFERRED_LENGTH, &count, &totalCount, &hEnumResume); if (enumResult == NERR_Success || enumResult == ERROR_MORE_DATA) { for (unsigned int i = 0; i < count && !errorFlag; i++) { SHARE_INFO_1& curShare = shareInfos[i]; if ((curShare.shi1_type & STYPE_MASK) == STYPE_DISKTREE) { std::string shareNameUtf8; if (curShare.shi1_netname && curShare.shi1_netname[0] && g_charsetConverter.wToUTF8(curShare.shi1_netname, shareNameUtf8, true) && !shareNameUtf8.empty()) { CFileItemPtr pItem(new CFileItem(shareNameUtf8)); pItem->SetPath(urlPrefixForItems + shareNameUtf8 + '/'); pItem->m_bIsFolder = true; if ((curShare.shi1_type & STYPE_SPECIAL) != 0 || shareNameUtf8.back() == '$') pItem->SetProperty("file:hidden", true); items.Add(pItem); } else errorFlag = true; } } NetApiBufferFree(shareInfos); } } while (!errorFlag && enumResult == ERROR_MORE_DATA); if (enumResult != NERR_Success || errorFlag) return false; // do not touch 'items' with partial result, allow fallback to another shares enumeration method items.Append(locItems); // all shares loaded, store result return true; }
bool CGUIMediaWindow::GetFilteredItems(const CStdString &filter, CFileItemList &items) { CStdString trimmedFilter(filter); trimmedFilter.TrimLeft().ToLower(); if (trimmedFilter.IsEmpty()) return true; CFileItemList filteredItems; bool numericMatch = StringUtils::IsNaturalNumber(trimmedFilter); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items.Get(i); if (item->IsParentFolder()) { filteredItems.Add(item); continue; } // TODO: Need to update this to get all labels, ideally out of the displayed info (ie from m_layout and m_focusedLayout) // though that isn't practical. Perhaps a better idea would be to just grab the info that we should filter on based on // where we are in the library tree. // Another idea is tying the filter string to the current level of the tree, so that going deeper disables the filter, // but it's re-enabled on the way back out. CStdString match; /* if (item->GetFocusedLayout()) match = item->GetFocusedLayout()->GetAllText(); else if (item->GetLayout()) match = item->GetLayout()->GetAllText(); else*/ match = item->GetLabel(); // Filter label only for now if (numericMatch) StringUtils::WordToDigits(match); size_t pos = StringUtils::FindWords(match.c_str(), trimmedFilter.c_str()); if (pos != CStdString::npos) filteredItems.Add(item); } items.ClearItems(); items.Append(filteredItems); return (items.GetObjectCount() > 0); }
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items) { // Load in the SmartPlaylist and get the WHERE query CSmartPlaylist playlist; if (!playlist.Load(strPath)) return false; bool success = false, success2 = false; if (playlist.GetType().Equals("music") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; db.Open(); CStdString type=playlist.GetType(); if (type.IsEmpty()) type = "music"; if (playlist.GetType().Equals("mixed")) playlist.SetType("music"); CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause(); success = db.GetSongsByWhere("", whereOrder, items); db.Close(); playlist.SetType(type); } if (playlist.GetType().Equals("video") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; db.Open(); CStdString type=playlist.GetType(); if (playlist.GetType().Equals("mixed")) playlist.SetType("video"); CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause(); CFileItemList items2; success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2); db.Close(); items.Append(items2); playlist.SetType(type); } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("video")) return success2; else return success; }
void GUIFontManager::SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string ¤t, void *data) { CFileItemList items; CFileItemList items2; // find TTF fonts XFILE::CDirectory::GetDirectory("special://home/media/Fonts/", items2); if (XFILE::CDirectory::GetDirectory("special://xbmc/media/Fonts/", items)) { items.Append(items2); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr pItem = items[i]; if (!pItem->m_bIsFolder && URIUtils::HasExtension(pItem->GetLabel(), ".ttf")) { list.push_back(make_pair(pItem->GetLabel(), pItem->GetLabel())); } } } }
void CGUIMediaWindow::OnFilterItems(const CStdString &filter) { CStdString currentItem; int item = m_viewControl.GetSelectedItem(); if (item >= 0) currentItem = m_vecItems->Get(item)->GetPath(); m_viewControl.Clear(); CFileItemList items; items.Append(*m_unfilteredItems); if (GetFilteredItems(filter, items)) { m_vecItems->ClearItems(); m_vecItems->Append(items); SetProperty("filter", filter); } // and update our view control + buttons m_viewControl.SetItems(*m_vecItems); m_viewControl.SetSelectedItem(currentItem); UpdateButtons(); }
/** * This method tries to determine what type of disc is located in the given drive and starts to play the content appropriately. */ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */, bool startFromBeginning /* = false */) { bool bPlaying(false); CFileItemList vecItems; if ( !pDir->GetDirectory( strDrive, vecItems ) ) { return false; } // Sorting necessary for easier HDDVD handling vecItems.Sort(SortByLabel, SortOrderAscending); bool bAllowVideo = true; // bool bAllowPictures = true; bool bAllowMusic = true; if (!g_passwordManager.IsMasterLockUnlocked(false)) { bAllowVideo = !CProfilesManager::Get().GetCurrentProfile().videoLocked(); // bAllowPictures = !CProfilesManager::Get().GetCurrentProfile().picturesLocked(); bAllowMusic = !CProfilesManager::Get().GetCurrentProfile().musicLocked(); } // is this a root folder we have to check the content to determine a disc type if( bRoot ) { CStdString hddvdname = ""; CFileItemPtr phddvdItem; // check root folders next, for normal structured dvd's for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; // is the current item a (non system) folder? if (pItem->m_bIsFolder && pItem->GetPath() != "." && pItem->GetPath() != "..") { CStdString name = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(name); name = URIUtils::GetFileName(name); // Check if the current foldername indicates a DVD structure (name is "VIDEO_TS") if (name.Equals("VIDEO_TS") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CStdString path = URIUtils::AddFileToFolder(pItem->GetPath(), "VIDEO_TS.IFO"); if(!CFile::Exists(path)) path = URIUtils::AddFileToFolder(pItem->GetPath(), "video_ts.ifo"); CFileItemPtr item(new CFileItem(path, false)); item->SetLabel(g_mediaManager.GetDiskLabel(strDrive)); item->GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive); if (!startFromBeginning && !item->GetVideoInfoTag()->m_strFileNameAndPath.empty()) item->m_lStartOffset = STARTOFFSET_RESUME; g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.SetShuffle (PLAYLIST_VIDEO, false); g_playlistPlayer.Add(PLAYLIST_VIDEO, item); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); return true; } // Check if the current foldername indicates a Blu-Ray structure (default is "BDMV"). // A BR should also include an "AACS" folder for encryption, Sony-BRs can also include update folders for PS3 (PS3_UPDATE / PS3_VPRM). // ToDo: for the time beeing, the DVD autorun settings are used to determine if the BR should be started automatically. if (name.Equals("BDMV") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CFileItemPtr item(new CFileItem(URIUtils::AddFileToFolder(pItem->GetPath(), "index.bdmv"), false)); item->SetLabel(g_mediaManager.GetDiskLabel(strDrive)); item->GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive); if (!startFromBeginning && !item->GetVideoInfoTag()->m_strFileNameAndPath.empty()) item->m_lStartOffset = STARTOFFSET_RESUME; g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.SetShuffle (PLAYLIST_VIDEO, false); g_playlistPlayer.Add(PLAYLIST_VIDEO, item); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); return true; } // Check if the current foldername indicates a HD DVD structure (default is "HVDVD_TS"). // Most HD DVD will also include an "ADV_OBJ" folder for advanced content. This folder should be handled first. // ToDo: for the time beeing, the DVD autorun settings are used to determine if the HD DVD should be started automatically. CFileItemList items, sitems; // Advanced Content HD DVD (most discs?) if (name.Equals("ADV_OBJ")) { CLog::Log(LOGINFO,"HD DVD: Checking for playlist."); // find playlist file CDirectory::GetDirectory(pItem->GetPath(), items, "*.xpl"); if (items.Size()) { // HD DVD Standard says the highest numbered playlist has to be handled first. CLog::Log(LOGINFO,"HD DVD: Playlist found. Set filetypes to *.xpl for external player."); items.Sort(SortByLabel, SortOrderDescending); phddvdItem = pItem; hddvdname = URIUtils::GetFileName(items[0]->GetPath()); CLog::Log(LOGINFO,"HD DVD: %s", items[0]->GetPath().c_str()); } } // Standard Content HD DVD (few discs?) if (name.Equals("HVDVD_TS") && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { if (hddvdname == "") { CLog::Log(LOGINFO,"HD DVD: Checking for ifo."); // find Video Manager or Title Set Information CDirectory::GetDirectory(pItem->GetPath(), items, "HV*.ifo"); if (items.Size()) { // HD DVD Standard says the lowest numbered ifo has to be handled first. CLog::Log(LOGINFO,"HD DVD: IFO found. Set filename to HV* and filetypes to *.ifo for external player."); items.Sort(SortByLabel, SortOrderAscending); phddvdItem = pItem; hddvdname = URIUtils::GetFileName(items[0]->GetPath()); CLog::Log(LOGINFO,"HD DVD: %s",items[0]->GetPath().c_str()); } } // Find and sort *.evo files for internal playback. // While this algorithm works for all of my HD DVDs, it may fail on other discs. If there are very large extras which are // alphabetically before the main movie they will be sorted to the top of the playlist and get played first. CDirectory::GetDirectory(pItem->GetPath(), items, "*.evo"); if (items.Size()) { // Sort *.evo files in alphabetical order. items.Sort(SortByLabel, SortOrderAscending); int64_t asize = 0; int ecount = 0; // calculate average size of elements above 1gb for (int j = 0; j < items.Size(); j++) if (items[j]->m_dwSize > 1000000000) { ecount++; asize = asize + items[j]->m_dwSize; } asize = asize / ecount; // Put largest files in alphabetical order to top of new list. for (int j = 0; j < items.Size(); j++) if (items[j]->m_dwSize >= asize) sitems.Add (items[j]); // Sort *.evo files by size. items.Sort(SortBySize, SortOrderDescending); // Add other files with descending size to bottom of new list. for (int j = 0; j < items.Size(); j++) if (items[j]->m_dwSize < asize) sitems.Add (items[j]); // Replace list with optimized list. items.Clear(); items.Copy (sitems); sitems.Clear(); } if (hddvdname != "") { CFileItem item(URIUtils::AddFileToFolder(phddvdItem->GetPath(), hddvdname), false); item.SetLabel(g_mediaManager.GetDiskLabel(strDrive)); item.GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive); if (!startFromBeginning && !item.GetVideoInfoTag()->m_strFileNameAndPath.empty()) item.m_lStartOffset = STARTOFFSET_RESUME; // get playername CStdString hddvdplayer = CPlayerCoreFactory::Get().GetPlayerName(CPlayerCoreFactory::Get().GetDefaultPlayer(item)); // Single *.xpl or *.ifo files require an external player to handle playback. // If no matching rule was found, DVDPlayer will be default player. if (hddvdplayer != "DVDPlayer") { CLog::Log(LOGINFO,"HD DVD: External singlefile playback initiated: %s",hddvdname.c_str()); g_application.PlayFile(item, false); return true; } else CLog::Log(LOGINFO,"HD DVD: No external player found. Fallback to internal one."); } // internal *.evo playback. CLog::Log(LOGINFO,"HD DVD: Internal multifile playback initiated."); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.SetShuffle (PLAYLIST_VIDEO, false); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); return true; } // Video CDs can have multiple file formats. First we need to determine which one is used on the CD CStdString strExt; if (name.Equals("MPEGAV")) strExt = ".dat"; if (name.Equals("MPEG2")) strExt = ".mpg"; // If a file format was extracted we are sure this is a VCD. Autoplay if settings indicate we should. if (!strExt.empty() && bAllowVideo && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { CFileItemList items; CDirectory::GetDirectory(pItem->GetPath(), items, strExt); if (items.Size()) { items.Sort(SortByLabel, SortOrderAscending); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); return true; } } /* Probably want this if/when we add some automedia action dialog... else if (pItem->GetPath().Find("PICTURES") != -1 && bAllowPictures && (bypassSettings)) { bPlaying = true; CStdString strExec = StringUtils::Format("XBMC.RecursiveSlideShow(%s)", pItem->GetPath().c_str()); CBuiltins::Execute(strExec); return true; } */ } } } // check video first if (!nAddedToPlaylist && !bPlaying && (bypassSettings || CSettings::Get().GetBool("dvds.autorun"))) { // stack video files CFileItemList tempItems; tempItems.Append(vecItems); if (CSettings::Get().GetBool("myvideos.stackvideos")) tempItems.Stack(); CFileItemList itemlist; for (int i = 0; i < tempItems.Size(); i++) { CFileItemPtr pItem = tempItems[i]; if (!pItem->m_bIsFolder && pItem->IsVideo()) { bPlaying = true; if (pItem->IsStack()) { // TODO: remove this once the app/player is capable of handling stacks immediately CStackDirectory dir; CFileItemList items; dir.GetDirectory(pItem->GetPath(), items); itemlist.Append(items); } else itemlist.Add(pItem); } } if (itemlist.Size()) { if (!bAllowVideo) { if (!bypassSettings) return false; if (g_windowManager.GetActiveWindow() != WINDOW_VIDEO_FILES) if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; } g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, itemlist); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); } } // then music if (!bPlaying && (bypassSettings || CSettings::Get().GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsAudio()) { nAddedToPlaylist++; g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem); } } } /* Probably want this if/when we add some automedia action dialog... // and finally pictures if (!nAddedToPlaylist && !bPlaying && bypassSettings && bAllowPictures) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsPicture()) { bPlaying = true; CStdString strExec = StringUtils::Format("XBMC.RecursiveSlideShow(%s)", strDrive.c_str()); CBuiltins::Execute(strExec); break; } } } */ // check subdirs if we are not playing yet if (!bPlaying) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (pItem->m_bIsFolder) { if (pItem->GetPath() != "." && pItem->GetPath() != ".." ) { if (RunDisc(pDir, pItem->GetPath(), nAddedToPlaylist, false, bypassSettings, startFromBeginning)) { bPlaying = true; break; } } } // if (non system) folder } // for all items in directory } // if root folder return bPlaying; }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); std::string basePath; if (CSmartPlaylist::IsMusicType(m_type)) basePath = "musicdb://"; else basePath = "videodb://"; VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "movies") basePath += "movies/"; else if (m_type == "tvshows") { type = VIDEODB_CONTENT_TVSHOWS; basePath += "tvshows/"; } else if (m_type == "musicvideos") { type = VIDEODB_CONTENT_MUSICVIDEOS; basePath += "musicvideos/"; } else if (m_type == "episodes") { if (m_rule.m_field == FieldGenre || m_rule.m_field == FieldYear || m_rule.m_field == FieldStudio) type = VIDEODB_CONTENT_TVSHOWS; else type = VIDEODB_CONTENT_EPISODES; basePath += "tvshows/"; } int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type == "tvshows" || m_type == "episodes" || m_type == "movies") videodatabase.GetGenresNav(basePath + "genres/", items, type); else if (m_type == "songs" || m_type == "albums" || m_type == "artists" || m_type == "mixed") database.GetGenresNav("musicdb://genres/",items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetGenresNav("videodb://musicvideos/genres/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav(basePath, items, type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetArtistsNav("musicdb://artists/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("", items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetAlbumsNav("musicdb://albums/", items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("", items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav(basePath + "actors/",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetYearsNav("musicdb://years/", items); if (CSmartPlaylist::IsVideoType(m_type)) { CFileItemList items2; videodatabase.GetYearsNav(basePath + "years/", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav(basePath + "directors/", items, type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav(basePath + "studios/", items, type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav(basePath, items, type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle || (m_type == "tvshows" && m_rule.m_field == FieldTitle)) { videodatabase.GetTvShowsNav(basePath + "titles/", items); iLabel = 20343; } else if (m_rule.m_field == FieldTitle) { if (m_type == "songs" || m_type == "mixed") { database.GetSongsNav("musicdb://songs/", items, -1, -1, -1); iLabel = 134; } if (m_type == "movies") { videodatabase.GetMoviesNav(basePath + "titles/", items); iLabel = 20342; } if (m_type == "episodes") { videodatabase.GetEpisodesNav(basePath + "titles/-1/-1/", items); // we need to replace the db label (<season>x<episode> <title>) with the title only CLabelFormatter format("%T", ""); for (int i = 0; i < items.Size(); i++) format.FormatLabel(items[i].get()); iLabel = 20360; } if (m_type == "musicvideos" || m_type == "mixed") { videodatabase.GetMusicVideosNav(basePath + "titles/", items); iLabel = 20389; } } else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 if (CSmartPlaylist::IsVideoType(m_type)) XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); if (CSmartPlaylist::IsMusicType(m_type)) { CFileItemList items2; XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); items.Append(items2); } for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; // don't list unloadable smartplaylists or any referencable smartplaylists // which do not match the type of the current smartplaylist if (!playlist.Load(item->GetPath()) || (m_rule.m_field == FieldPlaylist && (!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) || (!playlist.GetGroup().empty() || playlist.IsGroupMixed())))) { items.Remove(i); i -= 1; continue; } if (!playlist.GetName().empty()) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *CMediaSourceSettings::GetInstance().GetSources("music"); if (CSmartPlaylist::IsVideoType(m_type)) { VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); std::string path = m_rule.GetParameter(); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://movies/sets/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "tvshows" || m_type == "episodes") type = VIDEODB_CONTENT_TVSHOWS; else if (m_type == "musicvideos") type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type != "movies") return; videodatabase.GetTagsNav(basePath + "tags/", items, type); iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SortByLabel, SortOrderAscending, CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); std::string strHeading = StringUtils::Format(g_localizeStrings.Get(13401).c_str(), g_localizeStrings.Get(iLabel).c_str()); pDialog->SetHeading(CVariant{std::move(strHeading)}); pDialog->SetMultiSelection(m_rule.m_field != FieldPlaylist && m_rule.m_field != FieldVirtualFolder); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->Open(); if (pDialog->IsConfirmed()) { m_rule.m_parameter.clear(); for (int i : pDialog->GetSelectedItems()) m_rule.m_parameter.push_back(items.Get(i)->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items) { // Load in the SmartPlaylist and get the WHERE query CSmartPlaylist playlist; if (!playlist.Load(strPath)) return false; bool success = false, success2 = false; if (playlist.GetType().Equals("tvshows")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items); items.SetContent("tvshows"); db.Close(); } else if (playlist.GetType().Equals("episodes")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items); items.SetContent("episodes"); db.Close(); } else if (playlist.GetType().Equals("movies")) { CVideoDatabase db; db.Open(); success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items, true); items.SetContent("movies"); db.Close(); } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; db.Open(); success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items); items.SetContent("albums"); db.Close(); } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; db.Open(); CStdString type=playlist.GetType(); if (type.IsEmpty()) type = "songs"; if (playlist.GetType().Equals("mixed")) playlist.SetType("songs"); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetSongsByWhere("", whereOrder, items); items.SetContent("songs"); db.Close(); playlist.SetType(type); } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; db.Open(); CStdString type=playlist.GetType(); if (playlist.GetType().Equals("mixed")) playlist.SetType("musicvideos"); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); CFileItemList items2; success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks??? db.Close(); items.Append(items2); if (items2.Size()) items.SetContent("musicvideos"); playlist.SetType(type); } // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("musicvideos")) return success2; else return success; }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type.Equals("tvshows")) type = VIDEODB_CONTENT_TVSHOWS; else if (m_type.Equals("musicvideos")) type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type.Equals("episodes")) type = VIDEODB_CONTENT_EPISODES; int iLabel = 0; if (m_rule.m_field == CSmartPlaylistRule::FIELD_GENRE) { if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies")) videodatabase.GetGenresNav("videodb://2/1/",items,type); else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("mixed")) database.GetGenresNav("musicdb://4/",items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_COUNTRY) { videodatabase.GetCountriesNav("videodb://2/1/",items,type); iLabel = 574; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ARTIST || m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetArtistsNav("musicdb://5/",items,-1,m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("",items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUM) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetAlbumsNav("musicdb://6/",items,-1,-1,-1,-1); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("",items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ACTOR) { videodatabase.GetActorsNav("",items,type); iLabel = 20337; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_DIRECTOR) { videodatabase.GetDirectorsNav("",items,type); iLabel = 20339; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_STUDIO) { videodatabase.GetStudiosNav("",items,type); iLabel = 572; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_WRITER) { videodatabase.GetWritersNav("",items,type); iLabel = 20417; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_TVSHOWTITLE) { videodatabase.GetTvShowsNav("",items); iLabel = 20343; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PLAYLIST) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 CStdString path = "special://videoplaylists/"; if (m_type.Equals("songs") || m_type.Equals("albums")) path = "special://musicplaylists/"; XFILE::CDirectory::GetDirectory(path, items, ".xsp",false,false,XFILE::DIR_CACHE_ONCE,true,true); iLabel = 559; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PATH) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *g_settings.GetSourcesFromType("music"); if (m_type != "songs") { VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); CGUIDialogFileBrowser::ShowAndGetDirectory(sources,g_localizeStrings.Get(657),m_rule.m_parameter,false); UpdateButtons(); return; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel)); pDialog->SetHeading(strHeading); pDialog->DoModal(); if (pDialog->GetSelectedLabel() > -1) { m_rule.m_parameter = pDialog->GetSelectedLabelText(); UpdateButtons(); } pDialog->Reset(); }
bool CMultiPathDirectory::GetDirectory(const CURL& url, CFileItemList &items) { CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", url.GetRedacted().c_str()); std::vector<std::string> vecPaths; if (!GetPaths(url, vecPaths)) return false; XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar CGUIDialogProgress* dlgProgress = NULL; unsigned int iFailures = 0; for (unsigned int i = 0; i < vecPaths.size(); ++i) { // show the progress dialog if we have passed our time limit if (progressTime.IsTimePast() && !dlgProgress) { dlgProgress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS); if (dlgProgress) { dlgProgress->SetHeading(CVariant{15310}); dlgProgress->SetLine(0, CVariant{15311}); dlgProgress->SetLine(1, CVariant{""}); dlgProgress->SetLine(2, CVariant{""}); dlgProgress->Open(); dlgProgress->ShowProgressBar(true); dlgProgress->SetProgressMax((int)vecPaths.size()*2); dlgProgress->Progress(); } } if (dlgProgress) { CURL url(vecPaths[i]); dlgProgress->SetLine(1, CVariant{url.GetWithoutUserDetails()}); dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } CFileItemList tempItems; CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str()); if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_flags)) items.Append(tempItems); else { CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str()); iFailures++; } if (dlgProgress) { dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } } if (dlgProgress) dlgProgress->Close(); if (iFailures == vecPaths.size()) return false; // merge like-named folders into a sub multipath:// style url MergeItems(items); return true; }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir /* = "" */, bool filter /* = false */) { bool success = false, success2 = false; std::vector<std::string> virtualFolders; SortDescription sorting; sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; sorting.sortAttributes = playlist.GetOrderAttributes(); if (CSettings::Get().GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = (SortAttribute)(sorting.sortAttributes | SortAttributeIgnoreArticle); items.SetSortIgnoreFolders((sorting.sortAttributes & SortAttributeIgnoreFolders) == SortAttributeIgnoreFolders); std::string option = !filter ? "xsp" : "filter"; const std::string& group = playlist.GetGroup(); bool isGrouped = !group.empty() && !StringUtils::EqualsNoCase(group, "none") && !playlist.IsGroupMixed(); // get all virtual folders and add them to the item list playlist.GetVirtualFolders(virtualFolders); for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); virtualFolder++) { CFileItemPtr pItem = CFileItemPtr(new CFileItem(*virtualFolder, true)); IFileDirectory *dir = CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get()); if (dir != NULL) { pItem->SetSpecialSort(SortSpecialOnTop); items.Add(pItem); delete dir; } } if (playlist.GetType() == "movies" || playlist.GetType() == "tvshows" || playlist.GetType() == "episodes") { CVideoDatabase db; if (db.Open()) { MediaType mediaType = MediaTypes::FromString(playlist.GetType()); std::string baseDir = strBaseDir; if (strBaseDir.empty()) { if (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode) baseDir = "videodb://tvshows/"; else if (mediaType == MediaTypeMovie) baseDir = "videodb://movies/"; else return false; if (!isGrouped) baseDir += "titles"; else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); if (mediaType == MediaTypeEpisode) baseDir += "-1/-1/"; } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well std::string xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) videoUrl.AddOption(option, xsp); else videoUrl.RemoveOption(option); CDatabase::Filter dbfilter; success = db.GetItems(videoUrl.ToString(), items, dbfilter, sorting); db.Close(); // if we retrieve a list of episodes and we didn't receive // a pre-defined base path, we need to fix it if (strBaseDir.empty() && mediaType == MediaTypeEpisode && !isGrouped) videoUrl.AppendPath("-1/-1/"); items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } else if (playlist.IsMusicType() || playlist.GetType().empty()) { CMusicDatabase db; if (db.Open()) { CSmartPlaylist plist(playlist); if (playlist.GetType() == "mixed" || playlist.GetType().empty()) plist.SetType("songs"); MediaType mediaType = MediaTypes::FromString(plist.GetType()); std::string baseDir = strBaseDir; if (strBaseDir.empty()) { baseDir = "musicdb://"; if (!isGrouped) { if (mediaType == MediaTypeArtist) baseDir += "artists"; else if (mediaType == MediaTypeAlbum) baseDir += "albums"; else if (mediaType == MediaTypeSong) baseDir += "songs"; else return false; } else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); } CMusicDbUrl musicUrl; if (!musicUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well std::string xsp; if (!plist.IsEmpty(filter)) { if (!plist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) musicUrl.AddOption(option, xsp); else musicUrl.RemoveOption(option); CDatabase::Filter dbfilter; success = db.GetItems(musicUrl.ToString(), items, dbfilter, sorting); db.Close(); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType() == "musicvideos" || playlist.GetType() == "mixed") { CVideoDatabase db; if (db.Open()) { CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType() == "mixed") mvidPlaylist.SetType("musicvideos"); std::string baseDir = strBaseDir; if (baseDir.empty()) { baseDir = "videodb://musicvideos/"; if (!isGrouped) baseDir += "titles"; else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well std::string xsp; if (!mvidPlaylist.IsEmpty(filter)) { if (!mvidPlaylist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) videoUrl.AddOption(option, xsp); else videoUrl.RemoveOption(option); CFileItemList items2; CDatabase::Filter dbfilter; success2 = db.GetItems(videoUrl.ToString(), items2, dbfilter, sorting); db.Close(); if (items.Size() <= 0) items.SetPath(videoUrl.ToString()); items.Append(items2); if (items2.Size()) { if (items.Size() > items2.Size()) items.SetContent("mixed"); else items.SetContent("musicvideos"); } items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } items.SetLabel(playlist.GetName()); if (isGrouped) items.SetContent(group); else items.SetContent(playlist.GetType()); items.SetProperty(PROPERTY_SORT_ORDER, (int)playlist.GetOrder()); items.SetProperty(PROPERTY_SORT_ASCENDING, playlist.GetOrderDirection() == SortOrderAscending); if (!group.empty()) { items.SetProperty(PROPERTY_GROUP_BY, group); items.SetProperty(PROPERTY_GROUP_MIXED, playlist.IsGroupMixed()); } // sort grouped list by label if (items.Size() > 1 && !group.empty()) items.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType() == "mixed") return success || success2; else if (playlist.GetType() == "musicvideos") return success2; else return success; }
/** * This method tries to determine what type of disc is located in the given drive and starts to play the content appropriately. */ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */, bool startFromBeginning /* = false */) { bool bPlaying(false); CFileItemList vecItems; if ( !pDir->GetDirectory( strDrive, vecItems ) ) { return false; } bool bAllowVideo = true; // bool bAllowPictures = true; bool bAllowMusic = true; if (!g_passwordManager.IsMasterLockUnlocked(false)) { bAllowVideo = !g_settings.GetCurrentProfile().videoLocked(); // bAllowPictures = !g_settings.GetCurrentProfile().picturesLocked(); bAllowMusic = !g_settings.GetCurrentProfile().musicLocked(); } // is this a root folder we have to check the content to determine a disc type if( bRoot ) { // check root folders next, for normal structured dvd's for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; // is the current item a (non system) folder? if (pItem->m_bIsFolder && pItem->GetPath() != "." && pItem->GetPath() != "..") { CStdString name = pItem->GetPath(); URIUtils::RemoveSlashAtEnd(name); name = URIUtils::GetFileName(name); // Check if the current foldername indicates a DVD structure (name is "VIDEO_TS") if (name.Equals("VIDEO_TS") && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) { CStdString path = URIUtils::AddFileToFolder(pItem->GetPath(), "VIDEO_TS.IFO"); if(!CFile::Exists(path)) path = URIUtils::AddFileToFolder(pItem->GetPath(), "video_ts.ifo"); CFileItem item(path, false); item.SetLabel(g_mediaManager.GetDiskLabel(strDrive)); item.GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive); if (!startFromBeginning && !item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty()) item.m_lStartOffset = STARTOFFSET_RESUME; g_application.PlayFile(item, false); bPlaying = true; return true; } // Check if the current foldername indicates a Blu-Ray structure (default is "BDMV"). // A BR should also include an "AACS" folder for encryption, Sony-BRs can also include update folders for PS3 (PS3_UPDATE / PS3_VPRM). // ToDo: for the time beeing, the DVD autorun settings are used to determine if the BR should be started automatically. if (name.Equals("BDMV") && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) { CFileItem item(URIUtils::AddFileToFolder(pItem->GetPath(), "index.bdmv"), false); item.SetLabel(g_mediaManager.GetDiskLabel(strDrive)); item.GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive); if (!startFromBeginning && !item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty()) item.m_lStartOffset = STARTOFFSET_RESUME; g_application.PlayFile(item, false); bPlaying = true; return true; } // Video CDs can have multiple file formats. First we need to determine which one is used on the CD CStdString strExt; if (name.Equals("MPEGAV")) strExt = ".dat"; if (name.Equals("MPEG2")) strExt = ".mpg"; // If a file format was extracted we are sure this is a VCD. Autoplay if settings indicate we should. if (!strExt.IsEmpty() && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) { CFileItemList items; CDirectory::GetDirectory(pItem->GetPath(), items, strExt); if (items.Size()) { items.Sort(SORT_METHOD_LABEL, SortOrderAscending); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); bPlaying = true; return true; } } /* Probably want this if/when we add some automedia action dialog... else if (pItem->GetPath().Find("PICTURES") != -1 && bAllowPictures && (bypassSettings)) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", pItem->GetPath().c_str()); CBuiltins::Execute(strExec); return true; } */ } } } // check video first if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("dvds.autorun"))) { // stack video files CFileItemList tempItems; tempItems.Append(vecItems); if (g_settings.m_videoStacking) tempItems.Stack(); CFileItemList itemlist; for (int i = 0; i < tempItems.Size(); i++) { CFileItemPtr pItem = tempItems[i]; if (!pItem->m_bIsFolder && pItem->IsVideo()) { bPlaying = true; if (pItem->IsStack()) { // TODO: remove this once the app/player is capable of handling stacks immediately CStackDirectory dir; CFileItemList items; dir.GetDirectory(pItem->GetPath(), items); itemlist.Append(items); } else itemlist.Add(pItem); } } if (itemlist.Size()) { if (!bAllowVideo) { if (!bypassSettings) return false; if (g_windowManager.GetActiveWindow() != WINDOW_VIDEO_FILES) if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; } g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, itemlist); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); } } // then music if (!bPlaying && (bypassSettings || g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsAudio()) { nAddedToPlaylist++; g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem); } } } /* Probably want this if/when we add some automedia action dialog... // and finally pictures if (!nAddedToPlaylist && !bPlaying && bypassSettings && bAllowPictures) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsPicture()) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", strDrive.c_str()); CBuiltins::Execute(strExec); break; } } } */ // check subdirs if we are not playing yet if (!bPlaying) { for (int i = 0; i < vecItems.Size(); i++) { CFileItemPtr pItem = vecItems[i]; if (pItem->m_bIsFolder) { if (pItem->GetPath() != "." && pItem->GetPath() != ".." ) { if (RunDisc(pDir, pItem->GetPath(), nAddedToPlaylist, false, bypassSettings, startFromBeginning)) { bPlaying = true; break; } } } // if (non system) folder } // for all items in directory } // if root folder return bPlaying; }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items) { bool success = false, success2 = false; std::set<CStdString> playlists; SortDescription sorting; sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; if (playlist.GetType().Equals("movies") || playlist.GetType().Equals("tvshows") || playlist.GetType().Equals("episodes")) { CVideoDatabase db; if (db.Open()) { MediaType mediaType = DatabaseUtils::MediaTypeFromString(playlist.GetType()); CStdString strBaseDir; switch (mediaType) { case MediaTypeTvShow: case MediaTypeEpisode: strBaseDir = "videodb://2/2/"; break; case MediaTypeMovie: strBaseDir = "videodb://1/2/"; break; default: return false; } CVideoDbUrl videoUrl; CStdString xsp; if (!videoUrl.FromString(strBaseDir) || !playlist.SaveAsJson(xsp, false)) return false; // store the smartplaylist as JSON in the URL as well videoUrl.AddOption("xsp", xsp); CDatabase::Filter filter; success = db.GetSortedVideos(mediaType, videoUrl.ToString(), sorting, items, filter, true); db.Close(); } } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; if (db.Open()) { CMusicDbUrl musicUrl; CStdString xsp; if (!musicUrl.FromString("musicdb://3/") || !playlist.SaveAsJson(xsp, false)) return false; // store the smartplaylist as JSON in the URL as well musicUrl.AddOption("xsp", xsp); CDatabase::Filter filter; success = db.GetAlbumsByWhere(musicUrl.ToString(), filter, items, sorting); items.SetContent("albums"); db.Close(); } } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; if (db.Open()) { CSmartPlaylist songPlaylist(playlist); if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed")) songPlaylist.SetType("songs"); CMusicDbUrl musicUrl; CStdString xsp; if (!musicUrl.FromString("musicdb://4/") || !songPlaylist.SaveAsJson(xsp, false)) return false; // store the smartplaylist as JSON in the URL as well musicUrl.AddOption("xsp", xsp); CDatabase::Filter filter; success = db.GetSongsByWhere(musicUrl.ToString(), filter, items, sorting); items.SetContent("songs"); db.Close(); } } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; if (db.Open()) { CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType().Equals("mixed")) mvidPlaylist.SetType("musicvideos"); CVideoDbUrl videoUrl; CStdString xsp; if (!videoUrl.FromString("videodb://3/2/") || !mvidPlaylist.SaveAsJson(xsp, false)) return false; // store the smartplaylist as JSON in the URL as well videoUrl.AddOption("xsp", xsp); CFileItemList items2; success2 = db.GetSortedVideos(MediaTypeMusicVideo, videoUrl.ToString(), sorting, items2); db.Close(); items.Append(items2); if (items2.Size()) { if (items.Size() > items2.Size()) items.SetContent("mixed"); else items.SetContent("musicvideos"); } } } items.SetLabel(playlist.GetName()); // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("musicvideos")) return success2; else return success; }
bool CMultiPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) { CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", strPath.c_str()); vector<CStdString> vecPaths; if (!GetPaths(strPath, vecPaths)) return false; unsigned int progressTime = CTimeUtils::GetTimeMS() + 3000L; // 3 seconds before showing progress bar CGUIDialogProgress* dlgProgress = NULL; unsigned int iFailures = 0; for (unsigned int i = 0; i < vecPaths.size(); ++i) { // show the progress dialog if we have passed our time limit if (CTimeUtils::GetTimeMS() > progressTime && !dlgProgress) { dlgProgress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (dlgProgress) { dlgProgress->SetHeading(15310); dlgProgress->SetLine(0, 15311); dlgProgress->SetLine(1, ""); dlgProgress->SetLine(2, ""); dlgProgress->StartModal(); dlgProgress->ShowProgressBar(true); dlgProgress->SetProgressMax((int)vecPaths.size()*2); dlgProgress->Progress(); } } if (dlgProgress) { CURL url(vecPaths[i]); dlgProgress->SetLine(1, url.GetWithoutUserDetails()); dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } CFileItemList tempItems; CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str()); if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_useFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo)) items.Append(tempItems); else { CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str()); iFailures++; } if (dlgProgress) { dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } } if (dlgProgress) dlgProgress->Close(); if (iFailures == vecPaths.size()) return false; // merge like-named folders into a sub multipath:// style url MergeItems(items); return true; }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const CStdString &strBaseDir /* = "" */, bool filter /* = false */) { bool success = false, success2 = false; std::set<CStdString> playlists; SortDescription sorting; sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; std::string option = !filter ? "xsp" : "filter"; if (playlist.GetType().Equals("movies") || playlist.GetType().Equals("tvshows") || playlist.GetType().Equals("episodes")) { CVideoDatabase db; if (db.Open()) { MediaType mediaType = DatabaseUtils::MediaTypeFromString(playlist.GetType()); CStdString baseDir = strBaseDir; if (strBaseDir.empty()) { switch (mediaType) { case MediaTypeTvShow: case MediaTypeEpisode: baseDir = "videodb://2/2/"; break; case MediaTypeMovie: baseDir = "videodb://1/2/"; break; default: return false; } } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } videoUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetSortedVideos(mediaType, videoUrl.ToString(), sorting, items, dbfilter, true); db.Close(); // if we retrieve a list of episodes and we didn't receive // a pre-defined base path, we need to fix it if (strBaseDir.empty() && mediaType == MediaTypeEpisode) videoUrl.AppendPath("-1/-1/"); items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; if (db.Open()) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://3/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetAlbumsByWhere(musicUrl.ToString(), dbfilter, items, sorting); db.Close(); items.SetContent("albums"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } else if (playlist.GetType().Equals("artists")) { CMusicDatabase db; if (db.Open()) { CMusicDbUrl musicUrl; if (!musicUrl.FromString("musicdb://2/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetArtistsNav(musicUrl.ToString(), items, !g_guiSettings.GetBool("musiclibrary.showcompilationartists"), -1, -1, -1, dbfilter, sorting); db.Close(); items.SetContent("artists"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; if (db.Open()) { CSmartPlaylist songPlaylist(playlist); if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed")) songPlaylist.SetType("songs"); CMusicDbUrl musicUrl; if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://4/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!songPlaylist.IsEmpty(filter)) { if (!songPlaylist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetSongsByWhere(musicUrl.ToString(), dbfilter, items, sorting); db.Close(); items.SetContent("songs"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; if (db.Open()) { CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType().Equals("mixed")) mvidPlaylist.SetType("musicvideos"); CVideoDbUrl videoUrl; if (!videoUrl.FromString(!strBaseDir.empty() ? strBaseDir : "videodb://3/2/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!mvidPlaylist.IsEmpty(filter)) { if (!mvidPlaylist.SaveAsJson(xsp, !filter)) return false; } videoUrl.AddOption(option, xsp); CFileItemList items2; success2 = db.GetSortedVideos(MediaTypeMusicVideo, videoUrl.ToString(), sorting, items2); db.Close(); items.Append(items2); if (items2.Size()) { if (items.Size() > items2.Size()) items.SetContent("mixed"); else items.SetContent("musicvideos"); } items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } items.SetLabel(playlist.GetName()); // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("musicvideos")) return success2; else return success; }
bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */) { bool bPlaying(false); CFileItemList vecItems; char szSlash = '\\'; if (strDrive.Find("iso9660") != -1) szSlash = '/'; if ( !pDir->GetDirectory( strDrive, vecItems ) ) { return false; } bool bAllowVideo = true; bool bAllowPictures = true; bool bAllowMusic = true; if (!g_passwordManager.IsMasterLockUnlocked(false)) { bAllowVideo = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].videoLocked(); bAllowPictures = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].picturesLocked(); bAllowMusic = !g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].musicLocked(); } if( bRoot ) { // check root folders first, for normal structured dvd's for (int i = 0; i < vecItems.Size(); i++) { CFileItem* pItem = vecItems[i]; if (pItem->m_bIsFolder && pItem->m_strPath != "." && pItem->m_strPath != "..") { if (pItem->m_strPath.Find( "VIDEO_TS" ) != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.dvd"))) { CUtil::PlayDVD(); bPlaying = true; return true; } else if (pItem->m_strPath.Find("MPEGAV") != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.vcd"))) { CFileItemList items; CDirectory::GetDirectory(pItem->m_strPath, items, ".dat"); if (items.Size()) { items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); bPlaying = true; return true; } } else if (pItem->m_strPath.Find("MPEG2") != -1 && bAllowVideo && (bypassSettings || g_guiSettings.GetBool("autorun.vcd"))) { CFileItemList items; CDirectory::GetDirectory(pItem->m_strPath, items, ".mpg"); if (items.Size()) { items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, items); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); bPlaying = true; return true; } } else if (pItem->m_strPath.Find("PICTURES") != -1 && bAllowPictures && (bypassSettings || g_guiSettings.GetBool("autorun.pictures"))) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", pItem->m_strPath.c_str()); CUtil::ExecBuiltIn(strExec); return true; } } } } // check video first if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.video"))) { // stack video files CFileItemList tempItems; tempItems.Append(vecItems); tempItems.Stack(); CFileItemList itemlist; for (int i = 0; i < tempItems.Size(); i++) { CFileItem *pItem = tempItems[i]; if (!pItem->m_bIsFolder && pItem->IsVideo()) { bPlaying = true; if (pItem->IsStack()) { // TODO: remove this once the app/player is capable of handling stacks immediately CStackDirectory dir; CFileItemList items; dir.GetDirectory(pItem->m_strPath, items); for (int i = 0; i < items.Size(); i++) { itemlist.Add(new CFileItem(*items[i])); } } else itemlist.Add(new CFileItem(*pItem)); } } if (itemlist.Size()) { if (!bAllowVideo) { if (!bypassSettings) return false; if (m_gWindowManager.GetActiveWindow() != WINDOW_VIDEO_FILES) if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; } g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Add(PLAYLIST_VIDEO, itemlist); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.Play(0); } } // then music if (!bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.music")) && bAllowMusic) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem *pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsAudio()) { nAddedToPlaylist++; g_playlistPlayer.Add(PLAYLIST_MUSIC, pItem); } } } // and finally pictures if (!nAddedToPlaylist && !bPlaying && (bypassSettings || g_guiSettings.GetBool("autorun.pictures")) && bAllowPictures) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem *pItem = vecItems[i]; if (!pItem->m_bIsFolder && pItem->IsPicture()) { bPlaying = true; CStdString strExec; strExec.Format("XBMC.RecursiveSlideShow(%s)", strDrive.c_str()); CUtil::ExecBuiltIn(strExec); break; } } } // check subdirs if we are not playing yet if (!bPlaying) { for (int i = 0; i < vecItems.Size(); i++) { CFileItem* pItem = vecItems[i]; if (pItem->m_bIsFolder) { if (pItem->m_strPath != "." && pItem->m_strPath != ".." ) { if (RunDisc(pDir, pItem->m_strPath, nAddedToPlaylist, false, bypassSettings)) { bPlaying = true; break; } } } } } return bPlaying; }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items) { bool success = false, success2 = false; std::set<CStdString> playlists; if (playlist.GetType().Equals("tvshows")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db); success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items); items.SetContent("tvshows"); db.Close(); } else if (playlist.GetType().Equals("episodes")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db); success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items); items.SetContent("episodes"); db.Close(); } else if (playlist.GetType().Equals("movies")) { CVideoDatabase db; db.Open(); success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items, true); items.SetContent("movies"); db.Close(); } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; db.Open(); success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items); items.SetContent("albums"); db.Close(); } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; db.Open(); CStdString whereOrder; if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed")) { CSmartPlaylist songPlaylist(playlist); songPlaylist.SetType("songs"); whereOrder = songPlaylist.GetWhereClause(db, playlists) + " " + songPlaylist.GetOrderClause(db); } else whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db); success = db.GetSongsByWhere("", whereOrder, items); items.SetContent("songs"); db.Close(); } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; db.Open(); CStdString whereOrder; if (playlist.GetType().Equals("mixed")) { CSmartPlaylist mvidPlaylist(playlist); mvidPlaylist.SetType("musicvideos"); whereOrder = mvidPlaylist.GetWhereClause(db, playlists) + " " + mvidPlaylist.GetOrderClause(db); } else whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db); CFileItemList items2; success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks??? db.Close(); items.Append(items2); if (items2.Size()) items.SetContent("musicvideos"); } items.SetLabel(playlist.GetName()); // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("musicvideos")) return success2; else return success; }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type.Equals("tvshows")) type = VIDEODB_CONTENT_TVSHOWS; else if (m_type.Equals("musicvideos")) type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type.Equals("episodes")) type = VIDEODB_CONTENT_EPISODES; int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies")) videodatabase.GetGenresNav("videodb://2/1/",items,type); else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("artists") || m_type.Equals("mixed")) database.GetGenresNav("musicdb://1/",items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav("videodb://2/1/",items,type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums") || m_type.Equals("artists")) database.GetArtistsNav("musicdb://2/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("",items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetAlbumsNav("musicdb://3/", items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("",items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav("",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetYearsNav("musicdb://9/", items); if (!m_type.Equals("songs") && !m_type.Equals("albums")) { CFileItemList items2; videodatabase.GetYearsNav("", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav("",items,type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav("",items,type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav("",items,type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle) { videodatabase.GetTvShowsNav("videodb://2/2/",items); iLabel = 20343; } else if (m_rule.m_field == FieldPlaylist) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 CStdString path = "special://videoplaylists/"; if (m_type.Equals("songs") || m_type.Equals("albums")) path = "special://musicplaylists/"; XFILE::CDirectory::GetDirectory(path, items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; if (playlist.OpenAndReadName(item->GetPath())) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *g_settings.GetSourcesFromType("music"); if (m_type != "songs") { VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); CStdString path = m_rule.GetLocalizedParameter(m_type); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { if (m_type == "movies") videodatabase.GetTagsNav("videodb://1/9/", items, VIDEODB_CONTENT_MOVIES); else return; iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel)); pDialog->SetHeading(strHeading); pDialog->SetMultiSelection(true); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->DoModal(); if (pDialog->IsConfirmed()) { const CFileItemList &items = pDialog->GetSelectedItems(); m_rule.m_parameter.clear(); for (int index = 0; index < items.Size(); index++) m_rule.m_parameter.push_back(items[index]->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
bool CVirtualPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) { CLog::Log(LOGDEBUG,"CVirtualPathDirectory::GetDirectory(%s)", strPath.c_str()); CMediaSource share; if (!GetMatchingSource(strPath, share)) return false; DWORD progressTime = timeGetTime() + 3000L; // 3 seconds before showing progress bar CGUIDialogProgress* dlgProgress = NULL; unsigned int iFailures = 0; for (int i = 0; i < (int)share.vecPaths.size(); ++i) { // show the progress dialog if we have passed our time limit if (timeGetTime() > progressTime && !dlgProgress) { dlgProgress = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (dlgProgress) { dlgProgress->SetHeading(15310); dlgProgress->SetLine(0, 15311); dlgProgress->SetLine(1, ""); dlgProgress->SetLine(2, ""); dlgProgress->StartModal(); dlgProgress->ShowProgressBar(true); dlgProgress->SetProgressMax((int)share.vecPaths.size()*2); dlgProgress->Progress(); } } if (dlgProgress) { CURL url(share.vecPaths[i]); CStdString strStripped; url.GetURLWithoutUserDetails(strStripped); dlgProgress->SetLine(1, strStripped); dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } CFileItemList tempItems; CLog::Log(LOGDEBUG,"Getting Directory (%s)", share.vecPaths[i].c_str()); if (CDirectory::GetDirectory(share.vecPaths[i], tempItems, m_strFileMask, m_useFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo)) items.Append(tempItems); else { CLog::Log(LOGERROR,"Error Getting Directory (%s)", share.vecPaths[i].c_str()); iFailures++; } if (dlgProgress) { dlgProgress->SetProgressAdvance(); dlgProgress->Progress(); } } if (dlgProgress) dlgProgress->Close(); if (iFailures == share.vecPaths.size()) return false; return true; }