コード例 #1
0
        /// <summary>
        /// Returns latest added movies from MyFilms plugin.
        /// </summary>
        /// <param name="type">Type of data to fetch</param>
        /// <returns>Resultset of matching data</returns>
        private LatestsCollection GetLatestMovies()
        {
            latestMyFilms = new LatestsCollection();
            latestMovies  = new Hashtable();

            try
            {
                List <MFMovie> movies = null;
                if (CurrentFacade.Type == LatestsFacadeType.Watched)
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Watched, 999, Utils.FacadeMaxNum);
                }
                else if (CurrentFacade.Type == LatestsFacadeType.Rated)
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Added, 999, 999);
                }
                else
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Added, 999, Utils.FacadeMaxNum, CurrentFacade.UnWatched);
                }

                CurrentFacade.HasNew = false;
                if (movies != null)
                {
                    int i0 = 1;
                    foreach (MFMovie movie in movies)
                    {
                        if (CurrentFacade.Type == LatestsFacadeType.Rated)
                        {
                            if (movie.Rating == 0.0)
                            {
                                continue;
                            }
                        }

                        string thumb = movie.Picture;
                        if (string.IsNullOrEmpty(thumb))
                        {
                            thumb = "DefaultVideoBig.png"; // "DefaultFolderBig.png";
                        }

                        DateTime dTmp  = DateTime.MinValue;
                        bool     isnew = false;
                        try
                        {
                            dTmp  = DateTime.Parse(movie.DateAdded);
                            isnew = (dTmp > Utils.NewDateTime) && (movie.WatchedCount <= 0);
                            if (isnew)
                            {
                                CurrentFacade.HasNew = true;
                            }
                        }
                        catch
                        {
                            isnew = false;
                        }

                        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(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner),
                                () => fclearart  = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt),
                                () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo),
                                () => fcd        = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt),
                                () => aposter    = UtilsFanartHandler.GetAnimatedForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesPoster),
                                () => abg        = UtilsFanartHandler.GetAnimatedForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesBackground)
                            );
                        }

                        latestMyFilms.Add(new Latest()
                        {
                            DateTimeAdded   = dTmp,
                            DateTimeWatched = dTmp,
                            Title           = movie.Title,
                            Genre           = movie.Category,
                            Thumb           = thumb,
                            Fanart          = movie.Fanart,
                            Rating          = movie.Rating.ToString(),
                            Runtime         = movie.Length.ToString(),
                            Year            = movie.Year.ToString(),
                            Banner          = fbanner,
                            ClearArt        = fclearart,
                            ClearLogo       = fclearlogo,
                            CD                 = fcd,
                            AnimatedPoster     = aposter,
                            AnimatedBackground = abg,
                            Playable           = movie,
                            Id                 = movie.ID.ToString(),
                            DBId               = movie.IMDBNumber,
                            IsNew              = isnew
                        });

                        latestMovies.Add(i0, movie);
                        Utils.ThreadToSleep();

                        i0++;
                        if (i0 == Utils.FacadeMaxNum)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetLatestMovies: " + ex.ToString());
            }

            Utils.SortLatests(ref latestMyFilms, CurrentFacade.Type, CurrentFacade.LeftToRight);

            if (latestMyFilms != null && !MainFacade)
            {
                logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMyFilms.Count);
            }

            return(latestMyFilms);
        }
コード例 #2
0
        /// <summary>
        /// Returns latest added movies from MyFilms plugin.
        /// </summary>
        /// <param name="type">Type of data to fetch</param>
        /// <returns>Resultset of matching data</returns>
        private LatestsCollection GetLatestMovies()
        {
            latestMyFilms = new LatestsCollection();
            latestMovies  = new Hashtable();

            try
            {
                List <MFMovie> movies = null;
                if (CurrentFacade.Type == LatestsFacadeType.Watched)
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Watched, 999, Utils.FacadeMaxNum);
                }
                else if (CurrentFacade.Type == LatestsFacadeType.Rated)
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Added, 999, 999);
                }
                else
                {
                    movies = BaseMesFilms.GetMostRecent(BaseMesFilms.MostRecentType.Added, 999, Utils.FacadeMaxNum, CurrentFacade.UnWatched);
                }

                CurrentFacade.HasNew = false;
                if (movies != null)
                {
                    int i0 = 1;
                    foreach (MFMovie movie in movies)
                    {
                        if (CurrentFacade.Type == LatestsFacadeType.Rated)
                        {
                            if (movie.Rating == 0.0)
                            {
                                continue;
                            }
                        }

                        string thumb = movie.Picture;
                        if (string.IsNullOrEmpty(thumb))
                        {
                            thumb = "DefaultVideoBig.png"; // "DefaultFolderBig.png";
                        }
                        string tDate = movie.DateAdded;
                        bool   isnew = false;
                        try
                        {
                            DateTime dTmp = DateTime.Parse(tDate);
                            tDate = String.Format("{0:" + Utils.DateFormat + "}", dTmp);

                            isnew = (dTmp > Utils.NewDateTime) && (movie.WatchedCount <= 0);
                            if (isnew)
                            {
                                CurrentFacade.HasNew = true;
                            }
                        }
                        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(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesBanner),
                                () => fclearart  = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearArt),
                                () => fclearlogo = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesClearLogo),
                                () => fcd        = UtilsFanartHandler.GetFanartTVForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.FanartTV.MoviesCDArt),
                                () => aposter    = UtilsFanartHandler.GetAnimatedForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesPoster),
                                () => abg        = UtilsFanartHandler.GetAnimatedForLatestMedia(movie.IMDBNumber, string.Empty, string.Empty, Utils.Animated.MoviesBackground)
                            );
                        }

                        latestMyFilms.Add(new Latest(tDate, thumb, movie.Fanart, movie.Title,
                                                     null, null, null,
                                                     movie.Category,
                                                     movie.Rating.ToString(),
                                                     Math.Round(movie.Rating, MidpointRounding.AwayFromZero).ToString(CultureInfo.CurrentCulture),
                                                     null,
                                                     movie.Length.ToString(), movie.Year.ToString(),
                                                     null, null, null,
                                                     movie, movie.ID.ToString(),
                                                     null, null,
                                                     fbanner, fclearart, fclearlogo, fcd,
                                                     aposter, abg,
                                                     isnew));
                        latestMyFilms[latestMyFilms.Count - 1].DateWatched = tDate;

                        latestMovies.Add(i0, movie);
                        Utils.ThreadToSleep();

                        i0++;
                        if (i0 == Utils.FacadeMaxNum)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetLatestMovies: " + ex.ToString());
            }

            Utils.SortLatests(ref latestMyFilms, CurrentFacade.Type, CurrentFacade.LeftToRight);

            if (latestMyFilms != null && !MainFacade)
            {
                logger.Debug("GetLatest: " + this.ToString() + ":" + CurrentFacade.ControlID + " - " + latestMyFilms.Count);
            }

            return(latestMyFilms);
        }