示例#1
0
        public FanartContainer(ImageEntityType imageType, object poster)
        {
            ImageType    = imageType;
            FanartObject = poster;

            switch (ImageType)
            {
            case ImageEntityType.TvDB_FanArt:
                TvDB_ImageFanartVM tvFanart = FanartObject as TvDB_ImageFanartVM;
                IsImageEnabled = tvFanart.Enabled == 1;
                IsImageDefault = tvFanart.IsImageDefault;
                FanartSource   = "TvDB";
                break;

            case ImageEntityType.MovieDB_FanArt:
                MovieDB_FanartVM movieFanart = FanartObject as MovieDB_FanartVM;
                IsImageEnabled = movieFanart.Enabled == 1;
                IsImageDefault = movieFanart.IsImageDefault;
                FanartSource   = "MovieDB";
                break;

            case ImageEntityType.Trakt_Fanart:
                Trakt_ImageFanartVM traktFanart = FanartObject as Trakt_ImageFanartVM;
                IsImageEnabled = traktFanart.Enabled == 1;
                IsImageDefault = traktFanart.IsImageDefault;
                FanartSource   = "Trakt";
                break;
            }
        }
示例#2
0
        public AniDB_Anime_DefaultImageVM(JMMServerBinary.Contract_AniDB_Anime_DefaultImage contract)
        {
            this.AniDB_Anime_DefaultImageID = contract.AniDB_Anime_DefaultImageID;
            this.AnimeID         = contract.AnimeID;
            this.ImageParentID   = contract.ImageParentID;
            this.ImageParentType = contract.ImageParentType;
            this.ImageType       = contract.ImageType;

            MoviePoster  = null;
            MovieFanart  = null;
            TVPoster     = null;
            TVFanart     = null;
            TVWideBanner = null;
            TraktPoster  = null;
            TraktFanart  = null;

            if (contract.MovieFanart != null)
            {
                MovieFanart = new MovieDB_FanartVM(contract.MovieFanart);
            }

            if (contract.MoviePoster != null)
            {
                MoviePoster = new MovieDB_PosterVM(contract.MoviePoster);
            }

            if (contract.TVPoster != null)
            {
                TVPoster = new TvDB_ImagePosterVM(contract.TVPoster);
            }

            if (contract.TVFanart != null)
            {
                TVFanart = new TvDB_ImageFanartVM(contract.TVFanart);
            }

            if (contract.TVWideBanner != null)
            {
                TVWideBanner = new TvDB_ImageWideBannerVM(contract.TVWideBanner);
            }

            if (contract.TraktPoster != null)
            {
                TraktPoster = new Trakt_ImagePosterVM(contract.TraktPoster);
            }

            if (contract.TraktFanart != null)
            {
                TraktFanart = new Trakt_ImageFanartVM(contract.TraktFanart);
            }
        }
示例#3
0
        public static void SetDefaultFanart(bool isDefault, FanartContainer fanart, int animeID)
        {
            if (!JMMServerVM.Instance.ServerOnline)
            {
                return;
            }

            try
            {
                switch (fanart.ImageType)
                {
                case ImageEntityType.TvDB_FanArt:
                    TvDB_ImageFanartVM tvFanart = fanart.FanartObject as TvDB_ImageFanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.SetDefaultImage(isDefault, animeID,
                                                                          tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt, (int)ImageSizeType.Fanart);
                    tvFanart.IsImageDefault = isDefault;
                    break;

                case ImageEntityType.Trakt_Fanart:
                    Trakt_ImageFanartVM traktFanart = fanart.FanartObject as Trakt_ImageFanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.SetDefaultImage(isDefault, animeID,
                                                                          traktFanart.Trakt_ImageFanartID, (int)ImageEntityType.Trakt_Fanart, (int)ImageSizeType.Fanart);
                    traktFanart.IsImageDefault = isDefault;
                    break;

                case ImageEntityType.MovieDB_FanArt:
                    MovieDB_FanartVM movieFanart = fanart.FanartObject as MovieDB_FanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.SetDefaultImage(isDefault, animeID,
                                                                          movieFanart.MovieDB_FanartID, (int)ImageEntityType.MovieDB_FanArt, (int)ImageSizeType.Fanart);
                    movieFanart.IsImageDefault = isDefault;
                    break;
                }
                fanart.IsImageDefault = isDefault;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
        public AniDB_Anime_DefaultImageVM(JMMServerBinary.Contract_AniDB_Anime_DefaultImage contract)
        {
            this.AniDB_Anime_DefaultImageID = contract.AniDB_Anime_DefaultImageID;
            this.AnimeID = contract.AnimeID;
            this.ImageParentID = contract.ImageParentID;
            this.ImageParentType = contract.ImageParentType;
            this.ImageType = contract.ImageType;

            MoviePoster = null;
            MovieFanart = null;
            TVPoster = null;
            TVFanart = null;
            TVWideBanner = null;
            TraktPoster = null;
            TraktFanart = null;

            if (contract.MovieFanart != null)
                MovieFanart = new MovieDB_FanartVM(contract.MovieFanart);

            if (contract.MoviePoster != null)
                MoviePoster = new MovieDB_PosterVM(contract.MoviePoster);

            if (contract.TVPoster != null)
                TVPoster = new TvDB_ImagePosterVM(contract.TVPoster);

            if (contract.TVFanart != null)
                TVFanart = new TvDB_ImageFanartVM(contract.TVFanart);

            if (contract.TVWideBanner != null)
                TVWideBanner = new TvDB_ImageWideBannerVM(contract.TVWideBanner);

            if (contract.TraktPoster != null)
                TraktPoster = new Trakt_ImagePosterVM(contract.TraktPoster);

            if (contract.TraktFanart != null)
                TraktFanart = new Trakt_ImageFanartVM(contract.TraktFanart);
        }
示例#5
0
        public static void EnableDisableFanart(bool enabled, FanartContainer fanart, int animeID)
        {
            try
            {
                if (!enabled && fanart.IsImageDefault)
                {
                    SetDefaultFanart(false, fanart, animeID);
                }

                switch (fanart.ImageType)
                {
                case ImageEntityType.TvDB_FanArt:
                    TvDB_ImageFanartVM tvFanart = fanart.FanartObject as TvDB_ImageFanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.EnableDisableImage(enabled, tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt);
                    tvFanart.Enabled = enabled ? 1 : 0;
                    break;

                case ImageEntityType.Trakt_Fanart:
                    Trakt_ImageFanartVM traktFanart = fanart.FanartObject as Trakt_ImageFanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.EnableDisableImage(enabled, traktFanart.Trakt_ImageFanartID, (int)ImageEntityType.Trakt_Fanart);
                    traktFanart.Enabled = enabled ? 1 : 0;
                    break;

                case ImageEntityType.MovieDB_FanArt:
                    MovieDB_FanartVM movieFanart = fanart.FanartObject as MovieDB_FanartVM;
                    JMMServerVM.Instance.clientBinaryHTTP.EnableDisableImage(enabled, movieFanart.MovieDB_FanartID, (int)ImageEntityType.MovieDB_FanArt);
                    movieFanart.Enabled = enabled ? 1 : 0;
                    break;
                }
                fanart.IsImageEnabled = enabled;
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write("SetDefaultPoster: " + ex.Message);
            }
        }
示例#6
0
        public void DownloadMovieDBFanart(MovieDB_FanartVM fanart, bool forceDownload)
        {
            if (string.IsNullOrEmpty(fanart.URL)) return;

            try
            {
                string url = fanart.URL;
                string filename = fanart.FullImagePath;

                ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.MovieDB_FanArt, fanart, forceDownload);

                // check if this file has already been downloaded and exists
                if (!req.ForceDownload)
                {
                    // check to make sure the file actually exists
                    if (!File.Exists(fanart.FullImagePath))
                    {
                        this.imagesToDownload.Add(req);
                        OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount));
                        return;
                    }

                    // the file exists so don't download it again
                    return;
                }

                this.imagesToDownload.Add(req);
                OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount));
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }
        }
示例#7
0
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeCrossRefs details)
        {
            AnimeID = details.AnimeID;

            AniDB_AnimeVM anime = JMMServerHelper.GetAnime(AnimeID);

            if (anime == null)
            {
                return;
            }



            // Trakt
            if (details.CrossRef_AniDB_Trakt != null)
            {
                CrossRef_AniDB_Trakt = new CrossRef_AniDB_TraktVM(details.CrossRef_AniDB_Trakt);
            }

            if (details.TraktShow != null)
            {
                TraktShow = new Trakt_ShowVM(details.TraktShow);
            }

            if (details.TraktImageFanart != null)
            {
                TraktImageFanart = new Trakt_ImageFanartVM(details.TraktImageFanart);

                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.Trakt_Fanart &&
                    anime.DefaultFanart.ImageParentID == TraktImageFanart.Trakt_ImageFanartID)
                {
                    isDefault = true;
                }

                TraktImageFanart.IsImageDefault = isDefault;

                AllFanarts.Add(new FanartContainer(ImageEntityType.Trakt_Fanart, TraktImageFanart));
            }

            if (details.TraktImagePoster != null)
            {
                TraktImagePoster = new Trakt_ImagePosterVM(details.TraktImagePoster);

                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.Trakt_Poster &&
                    anime.DefaultPoster.ImageParentID == TraktImagePoster.Trakt_ImagePosterID)
                {
                    isDefault = true;
                }

                TraktImagePoster.IsImageDefault = isDefault;

                AllPosters.Add(new PosterContainer(ImageEntityType.Trakt_Poster, TraktImagePoster));
            }

            if (CrossRef_AniDB_Trakt == null || TraktShow == null)
            {
                TraktCrossRefExists = false;
            }
            else
            {
                TraktCrossRefExists = true;
            }

            // TvDB
            if (details.CrossRef_AniDB_TvDB != null)
            {
                CrossRef_AniDB_TvDB = new List <CrossRef_AniDB_TvDBVMV2>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TvDBV2 contract in details.CrossRef_AniDB_TvDB)
                {
                    CrossRef_AniDB_TvDBVMV2 xref = new CrossRef_AniDB_TvDBVMV2(contract);
                    CrossRef_AniDB_TvDB.Add(xref);
                }
            }

            if (details.TvDBSeries != null)
            {
                TvDBSeries = new List <TvDB_SeriesVM>();
                foreach (JMMServerBinary.Contract_TvDB_Series contract in details.TvDBSeries)
                {
                    TvDB_SeriesVM tv = new TvDB_SeriesVM(contract);
                    TvDBSeries.Add(tv);
                }
            }

            foreach (JMMServerBinary.Contract_TvDB_Episode contract in details.TvDBEpisodes)
            {
                TvDBEpisodes.Add(new TvDB_EpisodeVM(contract));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImageFanart contract in details.TvDBImageFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.TvDB_FanArt &&
                    anime.DefaultFanart.ImageParentID == contract.TvDB_ImageFanartID)
                {
                    isDefault = true;
                }

                TvDB_ImageFanartVM tvFanart = new TvDB_ImageFanartVM(contract);
                tvFanart.IsImageDefault = isDefault;
                TvDBImageFanarts.Add(tvFanart);

                AllFanarts.Add(new FanartContainer(ImageEntityType.TvDB_FanArt, tvFanart));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImagePoster contract in details.TvDBImagePosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.TvDB_Cover &&
                    anime.DefaultPoster.ImageParentID == contract.TvDB_ImagePosterID)
                {
                    isDefault = true;
                }

                TvDB_ImagePosterVM tvPoster = new TvDB_ImagePosterVM(contract);
                tvPoster.IsImageDefault = isDefault;
                TvDBImagePosters.Add(tvPoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.TvDB_Cover, tvPoster));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImageWideBanner contract in details.TvDBImageWideBanners)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultWideBanner != null && anime.DefaultWideBanner.ImageParentType == (int)ImageEntityType.TvDB_Banner &&
                    anime.DefaultWideBanner.ImageParentID == contract.TvDB_ImageWideBannerID)
                {
                    isDefault = true;
                }

                TvDB_ImageWideBannerVM tvBanner = new TvDB_ImageWideBannerVM(contract);
                tvBanner.IsImageDefault = isDefault;
                TvDBImageWideBanners.Add(tvBanner);
            }

            if ((CrossRef_AniDB_TvDB == null || CrossRef_AniDB_TvDB.Count == 0) ||
                (TvDBSeries == null || TvDBSeries.Count == 0))
            {
                TvDBCrossRefExists = false;
            }
            else
            {
                TvDBCrossRefExists = true;
            }

            // MovieDB
            if (details.CrossRef_AniDB_MovieDB != null)
            {
                CrossRef_AniDB_MovieDB = new CrossRef_AniDB_OtherVM(details.CrossRef_AniDB_MovieDB);
            }

            if (details.MovieDBMovie != null)
            {
                MovieDB_Movie = new MovieDB_MovieVM(details.MovieDBMovie);
            }

            foreach (JMMServerBinary.Contract_MovieDB_Fanart contract in details.MovieDBFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.MovieDB_FanArt &&
                    anime.DefaultFanart.ImageParentID == contract.MovieDB_FanartID)
                {
                    isDefault = true;
                }

                MovieDB_FanartVM movieFanart = new MovieDB_FanartVM(contract);
                movieFanart.IsImageDefault = isDefault;
                MovieDBFanarts.Add(movieFanart);
                AllFanarts.Add(new FanartContainer(ImageEntityType.MovieDB_FanArt, movieFanart));
            }

            foreach (JMMServerBinary.Contract_MovieDB_Poster contract in details.MovieDBPosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.MovieDB_Poster &&
                    anime.DefaultPoster.ImageParentID == contract.MovieDB_PosterID)
                {
                    isDefault = true;
                }

                MovieDB_PosterVM moviePoster = new MovieDB_PosterVM(contract);
                moviePoster.IsImageDefault = isDefault;
                MovieDBPosters.Add(moviePoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, moviePoster));
            }

            if (CrossRef_AniDB_MovieDB == null || MovieDB_Movie == null)
            {
                MovieDBCrossRefExists = false;
            }
            else
            {
                MovieDBCrossRefExists = true;
            }
        }
示例#8
0
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeCrossRefs details)
        {
            AnimeID = details.AnimeID;

            AniDB_AnimeVM anime = JMMServerHelper.GetAnime(AnimeID);
            if (anime == null) return;

            // Trakt
            if (details.CrossRef_AniDB_Trakt != null)
                CrossRef_AniDB_Trakt = new CrossRef_AniDB_TraktVM(details.CrossRef_AniDB_Trakt);

            if (details.TraktShow != null)
                TraktShow = new Trakt_ShowVM(details.TraktShow);

            if (details.TraktImageFanart != null)
            {
                TraktImageFanart = new Trakt_ImageFanartVM(details.TraktImageFanart);

                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.Trakt_Fanart
                    && anime.DefaultFanart.ImageParentID == TraktImageFanart.Trakt_ImageFanartID)
                {
                    isDefault = true;
                }

                TraktImageFanart.IsImageDefault = isDefault;

                AllFanarts.Add(new FanartContainer(ImageEntityType.Trakt_Fanart, TraktImageFanart));
            }

            if (details.TraktImagePoster != null)
            {
                TraktImagePoster = new Trakt_ImagePosterVM(details.TraktImagePoster);

                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.Trakt_Poster
                    && anime.DefaultPoster.ImageParentID == TraktImagePoster.Trakt_ImagePosterID)
                {
                    isDefault = true;
                }

                TraktImagePoster.IsImageDefault = isDefault;

                AllPosters.Add(new PosterContainer(ImageEntityType.Trakt_Poster, TraktImagePoster));
            }

            if (CrossRef_AniDB_Trakt == null || TraktShow == null)
                TraktCrossRefExists = false;
            else
                TraktCrossRefExists = true;

            // TvDB
            if (details.CrossRef_AniDB_TvDB != null)
            {
                CrossRef_AniDB_TvDB = new List<CrossRef_AniDB_TvDBVMV2>();
                foreach (JMMServerBinary.Contract_CrossRef_AniDB_TvDBV2 contract in details.CrossRef_AniDB_TvDB)
                {
                    CrossRef_AniDB_TvDBVMV2 xref = new CrossRef_AniDB_TvDBVMV2(contract);
                    CrossRef_AniDB_TvDB.Add(xref);
                }
            }

            if (details.TvDBSeries != null)
            {
                TvDBSeries = new List<TvDB_SeriesVM>();
                foreach (JMMServerBinary.Contract_TvDB_Series contract in details.TvDBSeries)
                {
                    TvDB_SeriesVM tv = new TvDB_SeriesVM(contract);
                    TvDBSeries.Add(tv);
                }
            }

            foreach (JMMServerBinary.Contract_TvDB_Episode contract in details.TvDBEpisodes)
                TvDBEpisodes.Add(new TvDB_EpisodeVM(contract));

            foreach (JMMServerBinary.Contract_TvDB_ImageFanart contract in details.TvDBImageFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.TvDB_FanArt
                    && anime.DefaultFanart.ImageParentID == contract.TvDB_ImageFanartID)
                {
                    isDefault = true;
                }

                TvDB_ImageFanartVM tvFanart = new TvDB_ImageFanartVM(contract);
                tvFanart.IsImageDefault = isDefault;
                TvDBImageFanarts.Add(tvFanart);

                AllFanarts.Add(new FanartContainer(ImageEntityType.TvDB_FanArt, tvFanart));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImagePoster contract in details.TvDBImagePosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.TvDB_Cover
                    && anime.DefaultPoster.ImageParentID == contract.TvDB_ImagePosterID)
                {
                    isDefault = true;
                }

                TvDB_ImagePosterVM tvPoster = new TvDB_ImagePosterVM(contract);
                tvPoster.IsImageDefault = isDefault;
                TvDBImagePosters.Add(tvPoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.TvDB_Cover, tvPoster));
            }

            foreach (JMMServerBinary.Contract_TvDB_ImageWideBanner contract in details.TvDBImageWideBanners)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultWideBanner != null && anime.DefaultWideBanner.ImageParentType == (int)ImageEntityType.TvDB_Banner
                    && anime.DefaultWideBanner.ImageParentID == contract.TvDB_ImageWideBannerID)
                {
                    isDefault = true;
                }

                TvDB_ImageWideBannerVM tvBanner = new TvDB_ImageWideBannerVM(contract);
                tvBanner.IsImageDefault = isDefault;
                TvDBImageWideBanners.Add(tvBanner);
            }

            if ((CrossRef_AniDB_TvDB == null || CrossRef_AniDB_TvDB.Count ==0) ||
                (TvDBSeries == null || TvDBSeries.Count == 0))
                TvDBCrossRefExists = false;
            else
                TvDBCrossRefExists = true;

            // MovieDB
            if (details.CrossRef_AniDB_MovieDB != null)
                CrossRef_AniDB_MovieDB = new CrossRef_AniDB_OtherVM(details.CrossRef_AniDB_MovieDB);

            if (details.MovieDBMovie != null)
                MovieDB_Movie = new MovieDB_MovieVM(details.MovieDBMovie);

            foreach (JMMServerBinary.Contract_MovieDB_Fanart contract in details.MovieDBFanarts)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultFanart != null && anime.DefaultFanart.ImageParentType == (int)ImageEntityType.MovieDB_FanArt
                    && anime.DefaultFanart.ImageParentID == contract.MovieDB_FanartID)
                {
                    isDefault = true;
                }

                MovieDB_FanartVM movieFanart = new MovieDB_FanartVM(contract);
                movieFanart.IsImageDefault = isDefault;
                MovieDBFanarts.Add(movieFanart);
                AllFanarts.Add(new FanartContainer(ImageEntityType.MovieDB_FanArt, movieFanart));
            }

            foreach (JMMServerBinary.Contract_MovieDB_Poster contract in details.MovieDBPosters)
            {
                bool isDefault = false;
                if (anime != null && anime.DefaultPoster != null && anime.DefaultPoster.ImageParentType == (int)ImageEntityType.MovieDB_Poster
                    && anime.DefaultPoster.ImageParentID == contract.MovieDB_PosterID)
                {
                    isDefault = true;
                }

                MovieDB_PosterVM moviePoster = new MovieDB_PosterVM(contract);
                moviePoster.IsImageDefault = isDefault;
                MovieDBPosters.Add(moviePoster);
                AllPosters.Add(new PosterContainer(ImageEntityType.MovieDB_Poster, moviePoster));
            }

            if (CrossRef_AniDB_MovieDB == null || MovieDB_Movie == null)
                MovieDBCrossRefExists = false;
            else
                MovieDBCrossRefExists = true;
        }