Exemple #1
0
        internal void GetLatestMediaInfo()
        {
            if (Interlocked.CompareExchange(ref CurrentFacade.Update, 1, 0) != 0)
            {
                return;
            }

            if (!Utils.LatestPictures)
            {
                EmptyLatestMediaProperties();
                CurrentFacade.Update = 0;
                return;
            }

            //Pictures
            try
            {
                LatestsCollection ht = GetLatestPictures();
                LatestsToFilmStrip(latestPictures);

                if (MainFacade || CurrentFacade.AddProperties)
                {
                    EmptyLatestMediaProperties();

                    if (ht != null)
                    {
                        Utils.FillLatestsPicturesProperty(CurrentFacade, ht, MainFacade);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("GetLatestMediaInfo (Pictures): " + ex.ToString());
            }

            if ((latestPictures != null) && (latestPictures.Count > 0))
            {
                InitFacade();
                Utils.SetProperty("#latestMediaHandler." + CurrentFacade.Handler.ToLowerInvariant() + (!MainFacade ? ".info." + CurrentFacade.ControlID.ToString() : string.Empty) + ".latest.enabled", "true");
            }
            else
            {
                EmptyLatestMediaProperties();
            }

            if (MainFacade)
            {
                Utils.UpdateLatestsUpdate(Utils.LatestsCategory.Pictures, DateTime.Now);
            }

            CurrentFacade.Update = 0;
        }
        internal void MyFilmsUpdateLatest()
        {
            if (Interlocked.CompareExchange(ref CurrentFacade.Update, 1, 0) != 0)
            {
                return;
            }

            if (!Utils.LatestMyFilms)
            {
                EmptyLatestMediaProperties();
                CurrentFacade.Update = 0;
                return;
            }

            // My Films
            LatestsCollection hTable = GetLatestMovies();

            LatestsToFilmStrip(latestMyFilms);

            if (MainFacade || CurrentFacade.AddProperties)
            {
                EmptyLatestMediaProperties();

                Utils.FillLatestsMovieProperty(CurrentFacade, hTable, MainFacade);
                if (hTable != null)
                {
                    int z = 1;
                    for (int i = 0; i < hTable.Count && i < Utils.LatestsMaxNum; i++)
                    {
                        Utils.SetProperty("#latestMediaHandler.myfilms" + (!MainFacade ? ".info." + CurrentFacade.ControlID.ToString() : string.Empty) + ".latest" + z + ".poster", hTable[i].Thumb);
                        z++;
                    }
                }
            }

            if ((latestMyFilms != null) && (latestMyFilms.Count > 0))
            {
                InitFacade();
                Utils.SetProperty("#latestMediaHandler." + CurrentFacade.Handler.ToLowerInvariant() + (!MainFacade ? ".info." + CurrentFacade.ControlID.ToString() : string.Empty) + ".latest.enabled", "true");
            }
            else
            {
                EmptyLatestMediaProperties();
            }

            if (MainFacade)
            {
                Utils.UpdateLatestsUpdate(Utils.LatestsCategory.MyFilms, DateTime.Now);
            }

            CurrentFacade.Update = 0;
        }
Exemple #3
0
        internal void GetLatestMediaInfo(bool _onStartUp)
        {
            // logger.Debug("*** mvCentral: GetLatestMediaInfo...") ;
            if (Interlocked.CompareExchange(ref CurrentFacade.Update, 1, 0) != 0)
            {
                return;
            }

            // logger.Debug("*** mvCentral: GetLatestMediaInfo...") ;
            artistsWithImageMissing = new Hashtable();
            if (!Utils.LatestMvCentral)
            {
                EmptyLatestMediaProperties();
                CurrentFacade.Update = 0;
                return;
            }

            //MvCentral
            LatestsCollection hTable = GetLatestMusic(_onStartUp);

            LatestsToFilmStrip(latestMusicAlbums);

            if (MainFacade || CurrentFacade.AddProperties)
            {
                EmptyLatestMediaProperties();

                if (hTable != null)
                {
                    Utils.FillLatestsMusicProperty(CurrentFacade, hTable, MainFacade);
                }
            }

            if ((latestMusicAlbums != null) && (latestMusicAlbums.Count > 0))
            {
                InitFacade();
                Utils.SetProperty("#latestMediaHandler." + CurrentFacade.Handler.ToLowerInvariant() + (!MainFacade ? ".info." + CurrentFacade.ControlID.ToString() : string.Empty) + ".latest.enabled", "true");
            }
            else
            {
                EmptyLatestMediaProperties();
            }

            if (MainFacade)
            {
                Utils.UpdateLatestsUpdate(Utils.LatestsCategory.MvCentral, DateTime.Now);
            }

            CurrentFacade.Update = 0;
        }
Exemple #4
0
        internal void LatestsToFilmStrip(LatestsCollection lTable)
        {
            if (lTable != null)
            {
                if (facadeCollection != null)
                {
                    facadeCollection.Clear();
                }

                for (int i = 0; i < lTable.Count; i++)
                {
                    AddToFilmstrip(lTable[i], i + 1);
                }
            }
        }
Exemple #5
0
        internal void MyVideosUpdateLatest()
        {
            if (Interlocked.CompareExchange(ref CurrentFacade.Update, 1, 0) != 0)
            {
                return;
            }

            if (!Utils.LatestMyVideos)
            {
                EmptyLatestMediaProperties();
                CurrentFacade.Update = 0;
                return;
            }

            //MyVideo
            LatestsCollection hTable = GetLatestMyVideos();

            LatestsToFilmStrip(latestMyVideos);

            if (MainFacade || CurrentFacade.AddProperties)
            {
                EmptyLatestMediaProperties();
                Utils.FillLatestsMovieProperty(CurrentFacade, hTable, MainFacade);
            }

            if ((latestMyVideos != null) && (latestMyVideos.Count > 0))
            {
                InitFacade();
                Utils.SetProperty("#latestMediaHandler." + CurrentFacade.Handler.ToLowerInvariant() + (!MainFacade ? ".info." + CurrentFacade.ControlID.ToString() : string.Empty) + ".latest.enabled", "true");
            }
            else
            {
                EmptyLatestMediaProperties();
            }

            if (MainFacade)
            {
                Utils.UpdateLatestsUpdate(Utils.LatestsCategory.Movies, DateTime.Now);
            }

            CurrentFacade.Update = 0;
        }
        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);
        }
Exemple #7
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);
        }
        /// <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);
        }
Exemple #9
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);
        }
Exemple #10
0
        /// <summary>
        /// Returns latest added Pictures db.
        /// </summary>
        /// <param name="type">Type of data to fetch</param>
        /// <returns>Resultset of matching data</returns>
        private LatestsCollection GetLatestPictures()
        {
            latestPictures      = new LatestsCollection();
            latestPicturesFiles = new Hashtable();

            if (!InitDB())
            {
                return(latestPictures);
            }

            int x = 0;

            try
            {
                CurrentFacade.HasNew = false;

                string          sqlQuery  = "SELECT strFile, strDateTaken FROM picture ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";";
                SQLiteResultSet resultSet = PicturesDB.Execute(sqlQuery);
                CloseDB();

                if (resultSet != null)
                {
                    if (resultSet.Rows.Count > 0)
                    {
                        int i0 = 1;
                        for (int i = 0; i < resultSet.Rows.Count; i++)
                        {
                            string filename = resultSet.GetField(i, 0);
                            if (string.IsNullOrEmpty(filename))
                            {
                                continue;
                            }

                            // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename));
                            string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename);
                            if (!File.Exists(thumb))
                            {
                                // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename));
                                thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename);
                                if (!File.Exists(thumb))
                                {
                                    // thumb = "DefaultPictureBig.png";
                                    thumb = filename;
                                }
                            }
                            if (!File.Exists(thumb))
                            {
                                continue;
                            }

                            string dateAdded = resultSet.GetField(i, 1);
                            bool   isnew     = false;
                            try
                            {
                                DateTime dTmp = DateTime.Parse(dateAdded);
                                dateAdded = String.Format("{0:" + Utils.DateFormat + "}", dTmp);

                                isnew = (dTmp > Utils.NewDateTime);
                                if (isnew)
                                {
                                    CurrentFacade.HasNew = true;
                                }
                            }
                            catch {   }

                            string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant();

                            string exif        = string.Empty;
                            string exifoutline = string.Empty;
                            if (File.Exists(filename))
                            {
                                using (ExifMetadata extractor = new ExifMetadata())
                                {
                                    ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename);

                                    exif = exif + (!string.IsNullOrEmpty(metaData.CameraModel.DisplayValue) ? metaData.CameraModel.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.DatePictureTaken.DisplayValue) ? metaData.DatePictureTaken.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.EquipmentMake.DisplayValue) ? metaData.EquipmentMake.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.ExposureCompensation.DisplayValue) ? metaData.ExposureCompensation.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.ExposureTime.DisplayValue) ?metaData.ExposureTime.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.Flash.DisplayValue) ? metaData.Flash.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.Fstop.DisplayValue) ? metaData.Fstop.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.ImageDimensions.DisplayValue) ? metaData.ImageDimensions.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.MeteringMode.DisplayValue) ? metaData.MeteringMode.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.Resolution.DisplayValue) ? metaData.Resolution.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.ShutterSpeed.DisplayValue) ? metaData.ShutterSpeed.DisplayValue + System.Environment.NewLine : string.Empty);
                                    exif = exif + (!string.IsNullOrEmpty(metaData.ViewerComments.DisplayValue) ? metaData.ViewerComments.DisplayValue + System.Environment.NewLine : string.Empty);

                                    exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.EquipmentMake.DisplayValue) ? metaData.EquipmentMake.DisplayValue + " " : string.Empty);
                                    exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.CameraModel.DisplayValue) ? metaData.CameraModel.DisplayValue + " " : string.Empty);
                                    exifoutline = exifoutline + (!string.IsNullOrEmpty(metaData.ViewerComments.DisplayValue) ? metaData.ViewerComments.DisplayValue + " " : string.Empty);
                                }
                            }

                            latestPictures.Add(new Latest(dateAdded, thumb, filename, title, exifoutline,
                                                          null, null, null, null, null, null,
                                                          null, null, null, null, null, null, null,
                                                          exif, null, isnew));
                            latestPicturesFiles.Add(i0, filename);
                            Utils.ThreadToSleep();

                            x++;
                            i0++;
                            if (x == Utils.FacadeMaxNum)
                            {
                                break;
                            }
                        }
                    }
                }
                resultSet = null;
            }
            catch (Exception ex)
            {
                logger.Error("GetLatestPictures: " + ex.ToString());
            }
            return(latestPictures);
        }
        internal void GetLatestMediaInfo()
        {
            int z = 1;

            if (Utils.LatestTVRecordings)
            {
                //TV Recordings
                LatestsCollection latestTVRecordings = null;
                try
                {
                    MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"));

                    string useArgus = xmlreader.GetValue("plugins", "ARGUS TV");
                    string dllFile  = Config.GetFile(Config.Dir.Plugins, @"Windows\ArgusTV.UI.MediaPortal.dll");

                    if (useArgus != null && useArgus.Equals("yes", StringComparison.CurrentCulture) && File.Exists(dllFile))
                    {
                        FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(dllFile);
                        logger.Debug("Argus version = {0}", myFileVersionInfo.FileVersion);

                        if (Largusrh == null)
                        {
                            Largusrh = new LatestArgusRecordingsHandler(this);
                        }

                        ResolveEventHandler assemblyResolve = Largusrh.OnAssemblyResolve;
                        try
                        {
                            AppDomain currentDomain = AppDomain.CurrentDomain;
                            currentDomain.AssemblyResolve        += new ResolveEventHandler(Largusrh.OnAssemblyResolve);
                            Largusrh.IsGetTypeRunningOnThisThread = true;
                            latestTVRecordings = Largusrh.GetArgusRecordings();
                            Largusrh.UpdateActiveRecordings();
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                            Utils.UsedArgus = true;
                        }
                        catch (FileNotFoundException)
                        {
                            //do nothing
                        }
                        catch (MissingMethodException)
                        {
                            //do nothing
                        }
                        catch (Exception ex)
                        {
                            logger.Error("GetLatestMediaInfo (TV Argus Recordings): " + ex.ToString());
                            AppDomain.CurrentDomain.AssemblyResolve -= assemblyResolve;
                        }
                    }
                    else
                    {
                        if (Ltvrh == null)
                        {
                            Ltvrh = new LatestTVRecordingsHandler(this);
                        }
                        latestTVRecordings = Ltvrh.GetTVRecordings();
                        Ltvrh.UpdateActiveRecordings();
                        Utils.UsedArgus = false;
                    }
                }
                catch (FileNotFoundException)
                {
                    //do nothing
                }
                catch (MissingMethodException)
                {
                    //do nothing
                }
                catch (Exception ex)
                {
                    logger.Error("GetLatestMediaInfo (TV Recordings): " + ex.ToString());
                }
                bool noNewRecordings = false;
                if ((latestTVRecordings != null && latestTVRecordings.Count > 0) &&
                    Utils.GetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title").Equals(latestTVRecordings[0].Title, StringComparison.CurrentCulture))
                {
                    noNewRecordings = true;
                    logger.Info("Updating Latest Media Info: TV Recording: No new recordings since last check!");
                }

                if (latestTVRecordings != null && latestTVRecordings.Count > 0)
                {
                    if (!noNewRecordings)
                    {
                        EmptyLatestMediaProperties();
                        z = 1;
                        for (int i = 0; i < latestTVRecordings.Count && i < Utils.LatestsMaxTVNum; i++)
                        {
                            logger.Info("Updating Latest Media Info: TV Recording: Recording " + z + ": " + latestTVRecordings[i].Title);

                            string recsummary        = (string.IsNullOrEmpty(latestTVRecordings[i].Summary) ? Translation.NoDescription : latestTVRecordings[i].Summary);
                            string recsummaryoutline = Utils.GetSentences(recsummary, Utils.LatestPlotOutlineSentencesNum);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".thumb", latestTVRecordings[i].Thumb);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".title", latestTVRecordings[i].Title);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".dateAdded", latestTVRecordings[i].DateAdded);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".genre", latestTVRecordings[i].Genre);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summary", recsummary);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".summaryoutline", recsummaryoutline);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".series", latestTVRecordings[i].SeriesIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episode", latestTVRecordings[i].EpisodeIndex);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".episodename", latestTVRecordings[i].ThumbSeries);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".directory", latestTVRecordings[i].Directory);
                            Utils.SetProperty("#latestMediaHandler.tvrecordings.latest" + z + ".new", latestTVRecordings[i].New);
                            z++;
                        }
                        //latestTVRecordings.Clear();
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.latest.enabled", "true");
                        Utils.SetProperty("#latestMediaHandler.tvrecordings.hasnew", CurrentFacade.HasNew ? "true" : "false");
                        logger.Debug("Updating Latest Media Info: TV Recording: Has new: " + (CurrentFacade.HasNew ? "true" : "false"));
                    }
                }
                else
                {
                    EmptyLatestMediaProperties();
                    logger.Info("Updating Latest Media Info: TV Recording: No recordings found!");
                }
                //latestTVRecordings = null;
                z = 1;
            }
            else
            {
                EmptyLatestMediaProperties();
            }
            Utils.UpdateLatestsUpdate(Utils.LatestsCategory.TV, DateTime.Now);
        }
        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);
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
0
        /// <summary>
        /// Returns latest added Pictures db.
        /// </summary>
        /// <param name="type">Type of data to fetch</param>
        /// <returns>Resultset of matching data</returns>
        private LatestsCollection GetLatestPictures()
        {
            latestPictures      = new LatestsCollection();
            latestPicturesFiles = new Hashtable();

            if (!PictureDatabase.DbHealth)
            {
                return(latestPictures);
            }

            int x = 0;

            try
            {
                CurrentFacade.HasNew = false;

                string sqlQuery = "SELECT strFile, strDateTaken FROM picture" +
                                  (PictureDatabase.FilterPrivate ? " WHERE idPicture NOT IN (SELECT DISTINCT idPicture FROM picturekeywords WHERE strKeyword = 'Private')" : string.Empty) +
                                  " ORDER BY strDateTaken DESC LIMIT " + Utils.FacadeMaxNum + ";";
                List <PictureData> pictures = PictureDatabase.GetPicturesByFilter(sqlQuery, "pictures");

                if (pictures != null)
                {
                    if (pictures.Count > 0)
                    {
                        int i0 = 1;
                        for (int i = 0; i < pictures.Count; i++)
                        {
                            string filename = pictures[i].FileName;
                            if (string.IsNullOrEmpty(filename))
                            {
                                continue;
                            }

                            // string thumb = String.Format(@"{0}\{1}L.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename));
                            string thumb = MediaPortal.Util.Utils.GetPicturesLargeThumbPathname(filename);
                            if (!File.Exists(thumb))
                            {
                                // thumb = String.Format(@"{0}\{1}.jpg", Thumbs.Pictures, MediaPortal.Util.Utils.EncryptLine(filename));
                                thumb = MediaPortal.Util.Utils.GetPicturesThumbPathname(filename);
                                if (!File.Exists(thumb))
                                {
                                    // thumb = "DefaultPictureBig.png";
                                    thumb = filename;
                                }
                            }
                            if (!File.Exists(thumb))
                            {
                                continue;
                            }

                            bool isnew = false;
                            isnew = (pictures[i].DateTaken > Utils.NewDateTime);
                            if (isnew)
                            {
                                CurrentFacade.HasNew = true;
                            }

                            string title = Path.GetFileNameWithoutExtension(Utils.GetFilenameNoPath(filename)).ToUpperInvariant();

                            string exif        = string.Empty;
                            string exifoutline = string.Empty;
                            if (File.Exists(filename))
                            {
                                using (ExifMetadata extractor = new ExifMetadata())
                                {
                                    ExifMetadata.Metadata metaData = extractor.GetExifMetadata(filename);

                                    if (!metaData.IsEmpty())
                                    {
                                        exif        = metaData.ToString();
                                        exifoutline = metaData.ToShortString();
                                    }
                                }
                            }

                            latestPictures.Add(new Latest()
                            {
                                DateTimeAdded  = pictures[i].DateTaken,
                                Title          = title,
                                Subtitle       = exifoutline,
                                Thumb          = thumb,
                                Fanart         = filename,
                                Classification = exif,
                                IsNew          = isnew
                            });

                            latestPicturesFiles.Add(i0, filename);
                            Utils.ThreadToSleep();

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