/// <summary> /// Create a Random Playlist of All Videos /// </summary> private void playRandomAll() { PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL); playlist.Clear(); List <DBTrackInfo> videos = DBTrackInfo.GetAll(); foreach (DBTrackInfo video in videos) { playlist.Add(new PlayListItem(video)); } Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlist.Shuffle(); Player.playlistPlayer.Play(0); if (mvCentralCore.Settings.AutoFullscreen) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); } }
/// <summary> /// Playlist startingh with the least played videos /// </summary> private void playLeastPlayed() { PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL); playlist.Clear(); List <DBTrackInfo> videos = DBTrackInfo.GetAll(); // Sort Most played first videos.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return(p1.UserSettings[0].WatchedCount.CompareTo(p2.UserSettings[0].WatchedCount)); }); // Now add to the list foreach (DBTrackInfo video in videos) { playlist.Add(new PlayListItem(video)); } Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; Player.playlistPlayer.Play(0); if (mvCentralCore.Settings.AutoFullscreen) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); } }
/// <summary> /// Play Tracks that have been added in the past X Days /// </summary> private void playFreshTracks() { PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL); playlist.Clear(); List <DBTrackInfo> videos = DBTrackInfo.GetAll(); videos.RemoveAll(video => video.DateAdded < DateTime.Now.Subtract(new TimeSpan(mvCentralCore.Settings.OldAFterDays, 0, 0, 0, 0))); foreach (DBTrackInfo video in videos) { playlist.Add(new PlayListItem(video)); } Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlist.Shuffle(); Player.playlistPlayer.Play(0); if (mvCentralCore.Settings.AutoFullscreen) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); } }
/// <summary> /// Create a Random Playlist of All HD Videos /// </summary> private void playRandomHDAll() { PlayList playlist = Player.playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MVCENTRAL); playlist.Clear(); List <DBTrackInfo> videos = DBTrackInfo.GetAll(); foreach (DBTrackInfo video in videos) { DBLocalMedia mediaInfo = (DBLocalMedia)video.LocalMedia[0]; if (mediaInfo.VideoResolution.StartsWith("1080") || mediaInfo.VideoResolution.StartsWith("720") || mediaInfo.VideoResolution.Equals("HD", StringComparison.OrdinalIgnoreCase)) { playlist.Add(new PlayListItem(video)); } } Player.playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_MVCENTRAL; playlist.Shuffle(); Player.playlistPlayer.Play(0); if (mvCentralCore.Settings.AutoFullscreen) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO); } }
public override void Work() { float count = 0; float total = DBTrackInfo.GetAll().Count; if (!mvCentralCore.Settings.AutoRetrieveMediaInfo) { return; } logger.Info("Begining background media info update process."); List <DBLocalMedia> allLocalMedia = DBLocalMedia.GetAll(); foreach (DBLocalMedia lm in allLocalMedia) { if (lm.ID != null && !lm.HasMediaInfo) { lm.UpdateMediaInfo(); lm.Commit(); } } foreach (DBTrackInfo currTrack in DBTrackInfo.GetAll()) { OnProgress((count * 100) / total); count++; // Check for Artist missing data try { if (currTrack.ID == null) { continue; } if (currTrack.ArtistInfo[0].DisallowBackgroundUpdate && !mvCentralCore.Settings.BackgroundScanAlways) { continue; } logger.Debug("Checking for Artist missing deails " + currTrack.GetType().ToString() + " CurrMusicVideo.ID : " + currTrack.Track); mvCentralCore.DataProviderManager.GetArtistDetail(currTrack); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currTrack.ID == null) { continue; } currTrack.Commit(); } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Artist details for " + currTrack.Basic, e); } // Check for Album missing data if album support enabled if (currTrack.AlbumInfo.Count > 0 && !mvCentralCore.Settings.DisableAlbumSupport) { try { if (currTrack.ID == null) { continue; } if (currTrack.ArtistInfo[0].DisallowBackgroundUpdate && !mvCentralCore.Settings.BackgroundScanAlways) { continue; } logger.Debug("Checking for Album missing deails " + currTrack.GetType().ToString() + " Title : " + currTrack.AlbumInfo[0].Album); mvCentralCore.DataProviderManager.GetAlbumDetail(currTrack); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currTrack.ID == null) { continue; } currTrack.Commit(); } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Album details for " + currTrack.Basic, e); } } // Prevent further background updates currTrack.ArtistInfo[0].DisallowBackgroundUpdate = true; if (currTrack.AlbumInfo.Count > 0) { currTrack.AlbumInfo[0].DisallowBackgroundUpdate = true; } currTrack.Commit(); } logger.Info("Background media info update process complete."); OnProgress(100.0); }
/// <summary> /// Remove Orphaned Artwork /// </summary> public void RemoveOrphanArtwork() { logger.Info("Checking for Orphaned Artwork...."); // Artist logger.Debug("Checking for Orphaned Artists Artwork...."); foreach (DBArtistInfo currMusicVideo in DBArtistInfo.GetAll()) { if (currMusicVideo.ID == null) { continue; } logger.Debug("Checking " + currMusicVideo.GetType().ToString() + " CurrArtist.ID : " + currMusicVideo.Artist); // get the list of elements to remove List <string> toRemove = new List <string>(); foreach (string currTrackArtPath in currMusicVideo.AlternateArts) { if (!new FileInfo(currTrackArtPath).Exists) { toRemove.Add(currTrackArtPath); } } // remove them foreach (string currItem in toRemove) { currMusicVideo.AlternateArts.Remove(currItem); } // reset default cover is needed if (!currMusicVideo.AlternateArts.Contains(currMusicVideo.ArtFullPath)) { if (currMusicVideo.AlternateArts.Count == 0) { currMusicVideo.ArtFullPath = " "; } else { currMusicVideo.ArtFullPath = currMusicVideo.AlternateArts[0]; } } // get rid of the backdrop link if it doesnt exist if (currMusicVideo.ArtFullPath.Trim().Length > 0 && !new FileInfo(currMusicVideo.ArtFullPath).Exists) { currMusicVideo.ArtFullPath = " "; } currMusicVideo.Commit(); } // Album logger.Debug("Checking for Orphaned Albums Artwork...."); foreach (DBAlbumInfo currMusicVideo in DBAlbumInfo.GetAll()) { if (currMusicVideo.ID == null) { continue; } logger.Debug("Checking " + currMusicVideo.GetType().ToString() + " CurrAlbum.ID : " + currMusicVideo.Album); // get the list of elements to remove List <string> toRemove = new List <string>(); foreach (string currTrackArtPath in currMusicVideo.AlternateArts) { if (!new FileInfo(currTrackArtPath).Exists) { toRemove.Add(currTrackArtPath); } } // remove them foreach (string currItem in toRemove) { currMusicVideo.AlternateArts.Remove(currItem); } // reset default cover is needed if (!currMusicVideo.AlternateArts.Contains(currMusicVideo.ArtFullPath)) { if (currMusicVideo.AlternateArts.Count == 0) { currMusicVideo.ArtFullPath = " "; } else { currMusicVideo.ArtFullPath = currMusicVideo.AlternateArts[0]; } } // get rid of the backdrop link if it doesnt exist if (currMusicVideo.ArtFullPath.Trim().Length > 0 && !new FileInfo(currMusicVideo.ArtFullPath).Exists) { currMusicVideo.ArtFullPath = " "; } currMusicVideo.Commit(); } // Track logger.Debug("Checking for Orphaned Tracks Artwork...."); foreach (DBTrackInfo currMusicVideo in DBTrackInfo.GetAll()) { if (currMusicVideo.ID == null) { continue; } logger.Debug("Checking " + currMusicVideo.GetType().ToString() + " CurrMusicVideo.ID : " + currMusicVideo.Track); // get the list of elements to remove List <string> toRemove = new List <string>(); foreach (string currTrackArtPath in currMusicVideo.AlternateArts) { if (!new FileInfo(currTrackArtPath).Exists) { toRemove.Add(currTrackArtPath); } } // remove them foreach (string currItem in toRemove) { currMusicVideo.AlternateArts.Remove(currItem); } // reset default cover is needed if (!currMusicVideo.AlternateArts.Contains(currMusicVideo.ArtFullPath)) { if (currMusicVideo.AlternateArts.Count == 0) { currMusicVideo.ArtFullPath = " "; } else { currMusicVideo.ArtFullPath = currMusicVideo.AlternateArts[0]; } } // get rid of the backdrop link if it doesnt exist if (currMusicVideo.ArtFullPath.Trim().Length > 0 && !new FileInfo(currMusicVideo.ArtFullPath).Exists) { currMusicVideo.ArtFullPath = " "; } currMusicVideo.Commit(); } }
/// <summary> /// This methoded checks for missing artwork and medatdata /// </summary> private void LookForMissingMetaData() { float count = 0; float total = DBArtistInfo.GetAll().Count + DBAlbumInfo.GetAll().Count + DBTrackInfo.GetAll().Count; // Check for missing Artist Artwork logger.Info("Checking for Missing Artwork (Artists)"); foreach (DBArtistInfo currArtist in DBArtistInfo.GetAll()) { OnProgress((count * 100) / total); count++; try { logger.Debug("Checking " + currArtist.GetType().ToString() + " CurrArtist.ID : " + currArtist.Artist); if (currArtist.ID == null) { continue; } if (currArtist.ArtFullPath.Trim().Length == 0) { mvCentralCore.DataProviderManager.GetArt(currArtist, false); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currArtist.ID == null) { continue; } currArtist.Commit(); } } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Artist artwork for " + currArtist.Basic, e); } } // Check for Missing Album Artwork logger.Info("Checking for Missing Artwork (Albums)"); foreach (DBAlbumInfo currAlbum in DBAlbumInfo.GetAll()) { OnProgress((count * 100) / total); count++; try { logger.Debug("Checking " + currAlbum.GetType().ToString() + " CurrAlbum.ID : " + currAlbum.Album); if (currAlbum.ID == null) { continue; } if (currAlbum.ArtFullPath.Trim().Length == 0) { mvCentralCore.DataProviderManager.GetArt(currAlbum, false); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currAlbum.ID == null) { continue; } currAlbum.Commit(); } } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.Error("Error retrieving Album artwork for " + currAlbum.Basic); } } // Check for missing video Artwork logger.Info("Checking for Missing Artwork (Videos)"); foreach (DBTrackInfo currTrack in DBTrackInfo.GetAll()) { OnProgress((count * 100) / total); count++; try { logger.Debug("Checking " + currTrack.GetType().ToString() + " CurrMusicVideo.ID : " + currTrack.Track); if (currTrack.ID == null) { continue; } if (currTrack.ArtFullPath.Trim().Length == 0) { mvCentralCore.DataProviderManager.GetArt(currTrack, false); // because this operation can take some time we check again // if the artist/album/track was not deleted while we were getting artwork if (currTrack.ID == null) { continue; } currTrack.Commit(); } } catch (Exception e) { if (e is ThreadAbortException) { throw e; } logger.ErrorException("Error retrieving Video artwork for " + currTrack.Basic, e); } } OnProgress(100.0); }
/// <summary> /// Returns last music track info added to MP music database. /// </summary> /// <returns>Hashtable containg artist names</returns> internal LatestsCollection GetLatestMusic(bool _onStartUp) { // logger.Debug("*** mvCentral: GetLatestMusic...") ; latestMusicAlbums = new LatestsCollection(); latestMusicAlbumsVideos = new Hashtable(); int x = 0; try { int i0 = 1; CurrentFacade.HasNew = false; List <DBTrackInfo> allTracks = DBTrackInfo.GetAll(); // logger.Debug("*** mvCentral: GetLatestMusic: "+allTracks.Count) ; if (allTracks.Count > 0) { allTracks.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return(p2.DateAdded.CompareTo(p1.DateAdded)); }); foreach (DBTrackInfo allTrack in allTracks) { bool isnew = false; string sArtist = string.Empty; string sArtistBio = string.Empty; string sArtistTag = string.Empty; string sGenre = string.Empty; string sAlbum = string.Empty; string sAlbumTag = string.Empty; string sYear = string.Empty; string artistThumb = string.Empty; string albumThumb = string.Empty; string trackThumb = string.Empty; string thumb = string.Empty; string sFileName = string.Empty; // Artist if (allTrack.ArtistInfo != null && allTrack.ArtistInfo.Count > 0) { sArtist = allTrack.ArtistInfo[0].Artist; sArtistBio = allTrack.ArtistInfo[0].bioSummary; sGenre = allTrack.ArtistInfo[0].Genre; artistThumb = allTrack.ArtistInfo[0].ArtFullPath; // ArtThumbFullPath foreach (string tag in allTrack.ArtistInfo[0].Tag) { sArtistTag += tag + "|"; } sArtistTag = Utils.GetDistinct(sArtistTag); } // Album if (allTrack.AlbumInfo != null && allTrack.AlbumInfo.Count > 0) { sAlbum = allTrack.AlbumInfo[0].Album; albumThumb = allTrack.AlbumInfo[0].ArtFullPath; foreach (string tag in allTrack.AlbumInfo[0].Tag) { sAlbumTag += tag + "|"; } sAlbumTag = Utils.GetDistinct(sAlbumTag); sYear = allTrack.AlbumInfo[0].YearReleased; } // Filename if (allTrack.LocalMedia != null && allTrack.LocalMedia.Count > 0) { sFileName = allTrack.LocalMedia[0].File.FullName; } // Genres or Tags: Artists genres -> Album tags -> Artist tags if (string.IsNullOrWhiteSpace(sGenre)) { sGenre = !string.IsNullOrWhiteSpace(sAlbumTag) ? sAlbumTag : sArtistTag; } // Thumb trackThumb = allTrack.ArtFullPath; switch (CurrentFacade.ThumbType) { case LatestsFacadeThumbType.Artist: thumb = !string.IsNullOrEmpty(artistThumb) ? artistThumb : "DefaultArtistBig.png"; break; case LatestsFacadeThumbType.Album: thumb = !string.IsNullOrEmpty(albumThumb) ? albumThumb : !string.IsNullOrEmpty(artistThumb) ? artistThumb : string.Empty; break; case LatestsFacadeThumbType.Track: thumb = !string.IsNullOrEmpty(trackThumb) ? trackThumb : !string.IsNullOrEmpty(albumThumb) ? artistThumb : !string.IsNullOrEmpty(artistThumb) ? artistThumb : string.Empty; break; } if (string.IsNullOrEmpty(thumb)) { thumb = "DefaultAudioBig.png"; } // Fanart string sFilename1 = string.Empty; string sFilename2 = string.Empty; try { Hashtable ht2 = (Utils.FanartHandler ? UtilsFanartHandler.GetMusicFanartForLatest(sArtist) : null); if (ht2 == null || ht2.Count < 1 && !_onStartUp) { if (Utils.FanartHandler) { UtilsFanartHandler.ScrapeFanartAndThumb(sArtist, string.Empty); ht2 = UtilsFanartHandler.GetMusicFanartForLatest(sArtist); } } if (ht2 == null || ht2.Count < 1) { if (Utils.FanartHandler) { if (!artistsWithImageMissing.Contains(UtilsFanartHandler.GetFHArtistName(sArtist))) { artistsWithImageMissing.Add(UtilsFanartHandler.GetFHArtistName(sArtist), UtilsFanartHandler.GetFHArtistName(sArtist)); } } else { if (!artistsWithImageMissing.Contains(sArtist)) { artistsWithImageMissing.Add(sArtist, sArtist); } } } if (ht2 != null) { IDictionaryEnumerator _enumerator = ht2.GetEnumerator(); int i = 0; while (_enumerator.MoveNext()) { if (i == 0) { sFilename1 = _enumerator.Value.ToString(); } if (i == 1) { sFilename2 = _enumerator.Value.ToString(); } i++; if (i > 1) { break; } } } } catch { } if (string.IsNullOrWhiteSpace(sFilename1)) { sFilename1 = sFilename2; } // Date added isnew = (allTrack.DateAdded > Utils.NewDateTime); if (isnew) { CurrentFacade.HasNew = true; } string fbanner = string.Empty; string fclearart = string.Empty; string fclearlogo = string.Empty; string fcd = string.Empty; if (Utils.FanartHandler) { Parallel.Invoke ( () => fbanner = UtilsFanartHandler.GetFanartTVForLatestMedia(sArtist, string.Empty, string.Empty, Utils.FanartTV.MusicBanner), () => fclearart = UtilsFanartHandler.GetFanartTVForLatestMedia(sArtist, string.Empty, string.Empty, Utils.FanartTV.MusicClearArt), // () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(sArtist, string.Empty, string.Empty, Utils.FanartTV.MusicClearArt), () => fcd = UtilsFanartHandler.GetFanartTVForLatestMedia(sArtist, sAlbum, string.Empty, Utils.FanartTV.MusicCDArt) ); fclearlogo = fclearart; } // Add to latest latestMusicAlbums.Add(new Latest() { DateTimeAdded = allTrack.DateAdded, Title = allTrack.Track, Subtitle = sFileName, Thumb = thumb, Fanart = sFilename1, Artist = sArtist, Album = sAlbum, Genre = sGenre, Rating = allTrack.Rating.ToString(), Year = sYear, SeasonIndex = artistThumb, EpisodeIndex = albumThumb, ThumbSeries = trackThumb, Summary = sArtistBio, Banner = fbanner, ClearArt = fclearart, ClearLogo = fclearlogo, CD = fcd, Playable = allTrack, IsNew = isnew }); latestMusicAlbumsVideos.Add(i0, sFileName); Utils.ThreadToSleep(); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } catch (Exception ex) { logger.Error("GetLatestMusic: " + ex.ToString()); } return(latestMusicAlbums); }
protected override void OnPageLoad() { base.OnPageLoad(); // Listen for background events mvCentralCore.ProcessManager.Progress += new ProcessProgressDelegate(ProcessManager_Progress); // Set initial propery valuesus GUIPropertyManager.SetProperty("#mvCentral.Metadata.Update.Progress", Localization.Inactive); GUIPropertyManager.SetProperty("#mvCentral.Artwork.Update.Progress", Localization.Inactive); GUILabelControl.SetControlLabel(GetID, (int)GUIControls.versionLabel, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); List <DBTrackInfo> videoList = DBTrackInfo.GetAll(); List <DBArtistInfo> artistList = DBArtistInfo.GetAll(); // Set stats GUILabelControl.SetControlLabel(GetID, (int)GUIControls.videoCountLabel, string.Format(Localization.VideoCount, videoList.Count, artistList.Count)); // Set Hierachy GUIPropertyManager.SetProperty("#mvCentral.Hierachy", Localization.History); // Get the most viewed video videoList.Sort(delegate(DBTrackInfo p1, DBTrackInfo p2) { return(p2.ActiveUserSettings.WatchedCount.CompareTo(p1.ActiveUserSettings.WatchedCount)); }); if (videoList[0].ActiveUserSettings.WatchedCount == 0) { GUIPropertyManager.SetProperty("#mvCentral.MostPlayed", " "); } else { GUIPropertyManager.SetProperty("#mvCentral.MostPlayed", videoList[0].Track); } favVideoImage.FileName = videoList[0].ArtFullPath; try { // Set the Top ten list - sure there is a neater way of doing this.... if (videoList[0].ActiveUserSettings.WatchedCount > 0) { topTen1.Label = string.Format(" 1 - {0} - {1}", videoList[0].ArtistInfo[0].Artist.ToString(), videoList[0].Track.ToString()); } if (videoList[1].ActiveUserSettings.WatchedCount > 0) { topTen2.Label = string.Format(" 2 - {0} - {1}", videoList[1].ArtistInfo[0].Artist, videoList[1].Track); } if (videoList[2].ActiveUserSettings.WatchedCount > 0) { topTen3.Label = string.Format(" 3 - {0} - {1}", videoList[2].ArtistInfo[0].Artist, videoList[2].Track); } if (videoList[3].ActiveUserSettings.WatchedCount > 0) { topTen4.Label = string.Format(" 4 - {0} - {1}", videoList[3].ArtistInfo[0].Artist, videoList[3].Track); } if (videoList[4].ActiveUserSettings.WatchedCount > 0) { topTen5.Label = string.Format(" 5 - {0} - {1}", videoList[4].ArtistInfo[0].Artist, videoList[4].Track); } if (videoList[5].ActiveUserSettings.WatchedCount > 0) { topTen6.Label = string.Format(" 6 - {0} - {1}", videoList[5].ArtistInfo[0].Artist, videoList[5].Track); } if (videoList[6].ActiveUserSettings.WatchedCount > 0) { topTen7.Label = string.Format(" 7 - {0} - {1}", videoList[6].ArtistInfo[0].Artist, videoList[6].Track); } if (videoList[7].ActiveUserSettings.WatchedCount > 0) { topTen8.Label = string.Format(" 8 - {0} - {1}", videoList[7].ArtistInfo[0].Artist, videoList[7].Track); } if (videoList[8].ActiveUserSettings.WatchedCount > 0) { topTen9.Label = string.Format(" 9 - {0} - {1}", videoList[8].ArtistInfo[0].Artist, videoList[8].Track); } if (videoList[9].ActiveUserSettings.WatchedCount > 0) { topTen10.Label = string.Format("10 - {0} - {1}", videoList[9].ArtistInfo[0].Artist, videoList[9].Track); } } catch { } // Get the most viewed artist int watchedCount = 0; int higestWatchCount = 0; DBArtistInfo mostWatchedArtist = null; foreach (DBArtistInfo artist in artistList) { List <DBTrackInfo> artistTracks = DBTrackInfo.GetEntriesByArtist(artist); watchedCount = 0; foreach (DBTrackInfo track in artistTracks) { watchedCount += track.ActiveUserSettings.WatchedCount; } if (watchedCount > higestWatchCount) { higestWatchCount = watchedCount; mostWatchedArtist = artist; } } if (mostWatchedArtist != null) { GUIPropertyManager.SetProperty("#mvCentral.FavArtist", mostWatchedArtist.Artist); favArtistImage.FileName = mostWatchedArtist.ArtThumbFullPath; } else { GUIPropertyManager.SetProperty("#mvCentral.FavArtist", " "); } }