コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }