internal LatestsCollection GetArgusRecordings() { UpdateSheduledTVRecordings(); LatestsCollection latests = new LatestsCollection(); LatestsCollection resultTmp = new LatestsCollection(); try { // parent.CurrentFacade.Facade = Utils.GetLatestsFacade(parent.CurrentFacade.ControlID); if (parent.CurrentFacade.Facade != null) { Utils.ClearFacade(ref parent.CurrentFacade.Facade); } if (facadeCollection != null) { facadeCollection.Clear(); } if (Proxies.IsInitialized) { List <RecordingSummary> recordings = null; DateTime _time = DateTime.Now; List <Channel> channels = new List <Channel>(); channels = Proxies.SchedulerService.GetAllChannels(ChannelType.Television).Result; List <Guid> chids = new List <Guid>(); foreach (Channel ch in channels) { chids.Add(ch.ChannelId); } IEnumerable <Guid> iechids = chids; List <List <RecordingSummary> > rr = new List <List <RecordingSummary> >(); rr = Proxies.ControlService.GetRecordingsOnChannels(iechids).Result; recordings = rr.SelectMany(z => z).ToList(); recordings.Sort(new RecordingsComparer()); if (recordings != null) { foreach (RecordingSummary rec in recordings) { logger.Debug("Recording: " + rec.ChannelId + " " + rec.RecordingStartTime.ToLocalTime() + " " + rec.Title); if (latests.Count > Utils.FacadeMaxNum) { break; } if (rec.ChannelType == ChannelType.Television) { Recording recording = Proxies.ControlService.GetRecordingById(rec.RecordingId).Result; string _summary = string.Empty; if (recording != null) { _summary = recording.Description; } string thumbNail = rec.ThumbnailFileName; if (!File.Exists(thumbNail)) { thumbNail = "defaultTVBig.png"; } if (Utils.LatestTVRecordingsWatched) { if (!rec.LastWatchedTime.HasValue) { latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), thumbNail, null, rec.Title, rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Category, null, null, null, null, null, null, null, null, rec, null, _summary, null)); } } else { latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), thumbNail, null, rec.Title, rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Category, null, null, null, null, null, null, null, null, rec, null, _summary, null)); } } Utils.ThreadToSleep(); } } int x = 0; int i0 = 1; if (latests != null && latests.Count > 0) { // latests.Sort(new LatestAddedComparerDesc()); Utils.SortLatests(ref latests, parent.CurrentFacade.Type, parent.CurrentFacade.LeftToRight); latestArgusRecordings = new Hashtable(); for (int x0 = 0; x0 < latests.Count; x0++) { //latests[x0].DateAdded = latests[x0].DateAdded.Substring(0, 10); try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); } catch { } latests[x0].Directory = Utils.GetGetDirectoryName(((RecordingSummary)latests[x0].Playable).RecordingFileName); latests[x0].Fanart = (Utils.FanartHandler ? UtilsFanartHandler.GetFanartForLatest(latests[x0].Title) : string.Empty); resultTmp.Add(latests[x0]); if (result == null || result.Count == 0) { result = resultTmp; } latestArgusRecordings.Add(i0, latests[x].Playable); //if (facade != null) //{ AddToFilmstrip(parent.CurrentFacade.Facade, latests[x], i0); //} x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } } } Utils.UpdateFacade(ref parent.CurrentFacade.Facade, parent.CurrentFacade); if (latests != null) { latests.Clear(); } latests = null; } catch { if (latests != null) { latests.Clear(); } latests = null; } result = resultTmp; return(result); }
private LatestsCollection GetLatestMovingPictures() { latestMovies = new LatestsCollection(); latestMovingPictures = new Hashtable(); LatestsCollection latests = new LatestsCollection(); try { List <DBMovieInfo> vMovies = null; if (Restricted) { vMovies = MovingPicturesCore.Settings.ParentalControlsFilter.Filter(DBMovieInfo.GetAll()).ToList(); } else { vMovies = DBMovieInfo.GetAll(); } foreach (var item in vMovies) { if (CurrentFacade.Type == LatestsFacadeType.Watched) { if (item.UserSettings[0].WatchedCount == 0) { continue; } } else if (CurrentFacade.UnWatched && (item.UserSettings[0].WatchedCount > 0)) { continue; } if (CurrentFacade.Type == LatestsFacadeType.Rated) { if (item.Score == 0.0) { continue; } } string sTimestamp = item.DateAdded.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture); string fanart = item.CoverThumbFullPath; if (string.IsNullOrEmpty(fanart)) { fanart = "DefaultVideoBig.png"; // "DefaultFolderBig.png"; } string fbanner = string.Empty; string fclearart = string.Empty; string fclearlogo = string.Empty; string fcd = string.Empty; string aposter = string.Empty; string abg = string.Empty; if (Utils.FanartHandler) { Parallel.Invoke ( () => fbanner = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner), () => fclearart = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt), () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo), () => fcd = UtilsFanartHandler.GetFanartTVForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt), () => aposter = UtilsFanartHandler.GetAnimatedForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.Animated.MoviesPoster), () => abg = UtilsFanartHandler.GetAnimatedForLatestMedia(item.ImdbID, string.Empty, string.Empty, Utils.Animated.MoviesBackground) ); } latests.Add(new Latest(sTimestamp, fanart, item.BackdropFullPath, item.Title, null, null, null, item.Genres.ToPrettyString(2), item.Score.ToString(CultureInfo.CurrentCulture), Math.Round(item.Score, MidpointRounding.AwayFromZero).ToString(CultureInfo.CurrentCulture), item.Certification, GetMovieRuntime(item), item.Year.ToString(CultureInfo.CurrentCulture), null, null, null, item, item.ID.ToString(), item.Summary, null, fbanner, fclearart, fclearlogo, fcd, aposter, abg)); if (item.WatchedHistory.Count > 0) { latests[latests.Count - 1].DateWatched = item.WatchedHistory[item.WatchedHistory.Count - 1].DateWatched.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture); } Utils.ThreadToSleep(); } if (vMovies != null) { vMovies.Clear(); } vMovies = null; CurrentFacade.HasNew = false; Utils.SortLatests(ref latests, CurrentFacade.Type, CurrentFacade.LeftToRight); int x = 0; for (int x0 = 0; x0 < latests.Count; x0++) { try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); DBMovieInfo Movie = (DBMovieInfo)latests[x0].Playable; latests[x0].IsNew = ((dTmp > Utils.NewDateTime) && (Movie.UserSettings[0].WatchedCount <= 0)); if (latests[x0].IsNew) { CurrentFacade.HasNew = true; } } catch { } latestMovies.Add(latests[x0]); latestMovingPictures.Add(x0 + 1, latests[x0].Playable); Utils.ThreadToSleep(); // logger.Debug("*** Latest [{7}] {0}:{1}:{2} - {3} - {4} {5} - {6}", x, CurrentFacade.Type, CurrentFacade.LeftToRight, latests[x0].Title, latests[x0].DateAdded, latests[x0].DateWatched, latests[x0].Rating, CurrentFacade.ControlID); x++; if (x == Utils.FacadeMaxNum) { break; } } } catch (Exception ex) { logger.Error("GetLatestMovingPictures: " + ex.ToString()); } if (latests != null) { latests.Clear(); } latests = null; if (latestMovies != null && !MainFacade) { logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMovies.Count); } return(latestMovies); }
/// <summary> /// Returns latest added movie thumbs from MyVideos db. /// </summary> /// <param name="type">Type of data to fetch</param> /// <returns>Resultset of matching data</returns> private LatestsCollection GetLatestMyVideos() { latestMyVideos = new LatestsCollection(); latestMyVideosForPlay = new Hashtable(); LatestsCollection latests = new LatestsCollection(); try { CurrentFacade.HasNew = false; ArrayList movies = new ArrayList(); string orderClause = "order by movieinfo."; switch (CurrentFacade.Type) { case LatestsFacadeType.Rated: orderClause = orderClause + "fRating"; break; case LatestsFacadeType.Watched: orderClause = orderClause + "dateWatched"; break; default: orderClause = orderClause + "dateAdded"; break; } orderClause = orderClause + " DESC limit 50"; string fromClause = "movie,movieinfo,path"; string whereClause = "where movieinfo.idmovie=movie.idmovie and movie.idpath=path.idpath"; if (CurrentFacade.Type == LatestsFacadeType.Watched) { whereClause = whereClause + " and movieinfo.iswatched=1"; } else if (CurrentFacade.UnWatched) { whereClause = whereClause + " and movieinfo.iswatched=0"; } string sql = String.Format("select movieinfo.fRating,movieinfo.strCredits,movieinfo.strTagLine,movieinfo.strPlotOutline, " + "movieinfo.strPlot,movieinfo.strPlotOutline,movieinfo.strVotes,movieinfo.strCast,movieinfo.iYear,movieinfo.strGenre,movieinfo.strPictureURL, " + "movieinfo.strTitle,path.strPath,movie.discid,movieinfo.IMDBID,movieinfo.idMovie,path.cdlabel,movieinfo.mpaa,movieinfo.runtime, " + "movieinfo.iswatched, movieinfo.dateAdded,movieinfo.dateWatched,movieinfo.studios from {0} {1} {2}", fromClause, whereClause, orderClause); VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false); int x = 0; foreach (IMDBMovie item in movies) { if (item.IsEmpty) { continue; } if (!CheckItem(item.Path)) { DateTime dTmp = DateTime.MinValue; DateTime dwTmp = DateTime.MinValue; string titleExt = item.Title + "{" + item.ID + "}"; string thumb = MediaPortal.Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt); //item.ThumbURL; if (string.IsNullOrEmpty(thumb)) { thumb = "DefaultVideoBig.png"; // "DefaultFolderBig.png"; } bool isnew = false; try { dTmp = DateTime.Parse(item.DateAdded); isnew = ((dTmp > Utils.NewDateTime) && (item.Watched <= 0)); if (isnew) { CurrentFacade.HasNew = true; } } catch { isnew = false; } try { dwTmp = DateTime.Parse(item.DateWatched); } catch { } string fbanner = string.Empty; string fclearart = string.Empty; string fclearlogo = string.Empty; string fcd = string.Empty; string aposter = string.Empty; string abg = string.Empty; if (Utils.FanartHandler) { Parallel.Invoke ( () => fbanner = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner), () => fclearart = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt), () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo), () => fcd = UtilsFanartHandler.GetFanartTVForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt), () => aposter = UtilsFanartHandler.GetAnimatedForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesPoster), () => abg = UtilsFanartHandler.GetAnimatedForLatestMedia(item.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesBackground) ); } latests.Add(new Latest() { DateTimeAdded = dTmp, DateTimeWatched = dwTmp, Title = item.Title, Subtitle = item.PlotOutline, Genre = item.Genre, Thumb = thumb, Fanart = GetFanart(item.Title, item.ID), Rating = item.Rating.ToString(CultureInfo.CurrentCulture), Classification = item.MPARating, Runtime = item.RunTime.ToString(), Year = item.Year.ToString(), Summary = item.Plot, Studios = item.Studios, Banner = fbanner, ClearArt = fclearart, ClearLogo = fclearlogo, CD = fcd, AnimatedPoster = aposter, AnimatedBackground = abg, Playable = item, Id = item.ID.ToString(), DBId = item.IMDBNumber, IsNew = isnew }); Utils.ThreadToSleep(); x++; if (x == Utils.FacadeMaxNum) { break; } } } if (movies != null) { movies.Clear(); } movies = null; Utils.SortLatests(ref latests, CurrentFacade.Type, CurrentFacade.LeftToRight); for (int x0 = 0; x0 < latests.Count; x0++) { latestMyVideos.Add(latests[x0]); latestMyVideosForPlay.Add(x0 + 1, latests[x0].Playable); } } catch (Exception ex) { logger.Error("GetLatestMyVideos: " + ex.ToString()); } if (latests != null) { latests.Clear(); } latests = null; if (latestMyVideos != null && !MainFacade) { logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMyVideos.Count); } return(latestMyVideos); }
internal LatestsCollection GetTVRecordings() { UpdateSheduledTVRecordings(); if (TVHome.Connected) { LatestMediaHandler.LatestsCollection resultTmp = new LatestMediaHandler.LatestsCollection(); LatestsCollection latests = new LatestsCollection(); try { IList <TvDatabase.Recording> recordings = TvDatabase.Recording.ListAll(); int x = 0; int i0 = 1; foreach (TvDatabase.Recording rec in recordings) { if (!Utils.LatestTVRecordingsUnfinished && IsRecordingActual(rec)) { continue; } if (Utils.LatestTVRecordingsWatched && (rec.TimesWatched > 0)) { continue; } latests.Add(new Latest(rec.StartTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), "defaultTVBig.png", null, rec.Title, rec.EndTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.CurrentCulture), null, null, rec.Genre, null, null, null, null, null, null, rec.EpisodeNum, rec.EpisodeName, rec, null, rec.Description, rec.SeriesNum)); Utils.ThreadToSleep(); } // parent.CurrentFacade.Facade = Utils.GetLatestsFacade(parent.CurrentFacade.ControlID); if (parent.CurrentFacade.Facade != null) { Utils.ClearFacade(ref parent.CurrentFacade.Facade); } if (facadeCollection != null) { facadeCollection.Clear(); } // latests.Sort(new LatestAddedComparerDesc()); Utils.SortLatests(ref latests, parent.CurrentFacade.Type, parent.CurrentFacade.LeftToRight); latestTVRecordings = new Hashtable(); for (int x0 = 0; x0 < latests.Count; x0++) { //latests[x0].DateAdded = latests[x0].DateAdded.Substring(0, 10); try { DateTime dTmp = DateTime.Parse(latests[x0].DateAdded); latests[x0].DateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp); } catch { } string _filename = ((Recording)latests[x0].Playable).FileName; string thumbNail = string.Empty; if (LatestMediaHandlerSetup.MpVersion.CompareTo("1.03") > 0) { // MP 1.4 logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.4 and above ..."); thumbNail = TVRecordingsThumbnailHandler.GetThumb(_filename); } else { // MP 1.3 or older logger.Debug("GetTVRecordings [" + LatestMediaHandlerSetup.MpVersion + "] Thumbs method: 1.3 or older ..."); thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}\\{1}{2}", Thumbs.TVRecorded, Path.ChangeExtension(MediaPortal.Util.Utils.SplitFilename(_filename), null), MediaPortal.Util.Utils.GetThumbExtension()); if (File.Exists(thumbNail)) { string tmpThumbNail = MediaPortal.Util.Utils.ConvertToLargeCoverArt(thumbNail); if (File.Exists(tmpThumbNail)) { thumbNail = tmpThumbNail; } } if (!File.Exists(thumbNail)) { thumbNail = string.Format(CultureInfo.CurrentCulture, "{0}{1}", Path.ChangeExtension(_filename, null), MediaPortal.Util.Utils.GetThumbExtension()); } if (!File.Exists(thumbNail)) { thumbNail = "defaultTVBig.png"; } } latests[x0].Fanart = (Utils.FanartHandler ? UtilsFanartHandler.GetFanartForLatest(latests[x0].Title) : string.Empty); latests[x0].Directory = Utils.GetGetDirectoryName(TVUtil.GetFileNameForRecording(((Recording)latests[x0].Playable))); latests[x0].Thumb = thumbNail; resultTmp.Add(latests[x0]); if (result == null || result.Count == 0) { result = resultTmp; } latestTVRecordings.Add(i0, latests[x].Playable); AddToFilmstrip(parent.CurrentFacade.Facade, latests[x], i0); x++; i0++; if (x == Utils.FacadeMaxNum) { break; } } Utils.UpdateFacade(ref parent.CurrentFacade.Facade, parent.CurrentFacade); if (latests != null) { latests.Clear(); } latests = null; } catch (FileNotFoundException) { //do nothing } catch (MissingMethodException) { //do nothing } catch (Exception ex) { if (latests != null) { latests.Clear(); } latests = null; logger.Error("GetTVRecordings: " + ex.ToString()); } result = resultTmp; } return(result); }