Exemple #1
0
        public void DownloadTraktFanart(VM_Trakt_ImageFanart fanart, bool forceDownload)
        {
            if (string.IsNullOrEmpty(fanart.ImageURL))
            {
                return;
            }

            try
            {
                ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.Trakt_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))
                    {
                        imagesToDownload.Add(req);
                        OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
                        return;
                    }

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

                imagesToDownload.Add(req);
                OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }
        }
Exemple #2
0
        public FanartContainer(ImageEntityType imageType, object poster)
        {
            ImageType    = imageType;
            FanartObject = poster;

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

            case ImageEntityType.MovieDB_FanArt:
                VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)FanartObject;
                IsImageEnabled = movieFanart.Enabled == 1;
                IsImageDefault = movieFanart.IsImageDefault;
                FanartSource   = "MovieDB";
                break;

            case ImageEntityType.Trakt_Fanart:
                VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart)FanartObject;
                IsImageEnabled = traktFanart.Enabled == 1;
                IsImageDefault = traktFanart.IsImageDefault;
                FanartSource   = "Trakt";
                break;
            }
        }
Exemple #3
0
        public static void SetDefaultFanart(bool isDefault, FanartContainer fanart, int animeID)
        {
            if (!VM_ShokoServer.Instance.ServerOnline)
            {
                return;
            }

            try
            {
                switch (fanart.ImageType)
                {
                case ImageEntityType.TvDB_FanArt:
                    VM_TvDB_ImageFanart tvFanart = (VM_TvDB_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt, (int)ImageSizeType.Fanart);
                    tvFanart.IsImageDefault = isDefault;
                    break;

                case ImageEntityType.Trakt_Fanart:
                    VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.SetDefaultImage(isDefault, animeID,
                                                                          traktFanart.Trakt_ImageFanartID, (int)ImageEntityType.Trakt_Fanart, (int)ImageSizeType.Fanart);
                    traktFanart.IsImageDefault = isDefault;
                    break;

                case ImageEntityType.MovieDB_FanArt:
                    VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.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 void DownloadTraktFanart(VM_Trakt_ImageFanart fanart, bool forceDownload)
        {
            if (string.IsNullOrEmpty(fanart.ImageURL))
            {
                return;
            }

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

                ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.Trakt_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))
                    {
                        imagesToDownload.Enqueue(req);
                        OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
                        return;
                    }

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

                imagesToDownload.Enqueue(req);
                OnQueueUpdateEvent(new QueueUpdateEventArgs(QueueCount));
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemple #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:
                    VM_TvDB_ImageFanart tvFanart = (VM_TvDB_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, tvFanart.TvDB_ImageFanartID, (int)ImageEntityType.TvDB_FanArt);
                    tvFanart.Enabled = enabled ? 1 : 0;
                    break;

                case ImageEntityType.Trakt_Fanart:
                    VM_Trakt_ImageFanart traktFanart = (VM_Trakt_ImageFanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.EnableDisableImage(enabled, traktFanart.Trakt_ImageFanartID, (int)ImageEntityType.Trakt_Fanart);
                    traktFanart.Enabled = enabled ? 1 : 0;
                    break;

                case ImageEntityType.MovieDB_FanArt:
                    VM_MovieDB_Fanart movieFanart = (VM_MovieDB_Fanart)fanart.FanartObject;
                    VM_ShokoServer.Instance.ShokoServices.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);
            }
        }
        private string GetEntityID(ImageDownloadRequest req)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                VM_AniDB_Anime anime = req.ImageData as VM_AniDB_Anime;
                return(anime.AnimeID.ToString());

            case ImageEntityType.TvDB_Cover:

                VM_TvDB_ImagePoster poster = req.ImageData as VM_TvDB_ImagePoster;
                return(poster.TvDB_ImagePosterID.ToString());

            case ImageEntityType.TvDB_Banner:

                VM_TvDB_ImageWideBanner banner = req.ImageData as VM_TvDB_ImageWideBanner;
                return(banner.TvDB_ImageWideBannerID.ToString());

            case ImageEntityType.TvDB_Episode:

                VM_TvDB_Episode episode = req.ImageData as VM_TvDB_Episode;
                return(episode.TvDB_EpisodeID.ToString());

            case ImageEntityType.TvDB_FanArt:

                VM_TvDB_ImageFanart fanart = req.ImageData as VM_TvDB_ImageFanart;
                return(fanart.TvDB_ImageFanartID.ToString());

            case ImageEntityType.MovieDB_Poster:

                VM_MovieDB_Poster moviePoster = req.ImageData as VM_MovieDB_Poster;
                return(moviePoster.MovieDB_PosterID.ToString());

            case ImageEntityType.MovieDB_FanArt:

                VM_MovieDB_Fanart movieFanart = req.ImageData as VM_MovieDB_Fanart;
                return(movieFanart.MovieDB_FanartID.ToString());

            case ImageEntityType.Trakt_Poster:

                VM_Trakt_ImagePoster traktPoster = req.ImageData as VM_Trakt_ImagePoster;
                return(traktPoster.Trakt_ImagePosterID.ToString());

            case ImageEntityType.Trakt_Fanart:

                VM_Trakt_ImageFanart trakFanart = req.ImageData as VM_Trakt_ImageFanart;
                return(trakFanart.Trakt_ImageFanartID.ToString());

            case ImageEntityType.Trakt_CommentUser:

                VM_Trakt_CommentUser traktShoutUser = req.ImageData as VM_Trakt_CommentUser;
                return(traktShoutUser.User.Trakt_FriendID.ToString());

            case ImageEntityType.Trakt_Episode:

                VM_Trakt_Episode trakEp = req.ImageData as VM_Trakt_Episode;
                return(trakEp.Trakt_EpisodeID.ToString());

            case ImageEntityType.AniDB_Character:

                VM_AniDB_Character chr = req.ImageData as VM_AniDB_Character;
                return(chr.AniDB_CharacterID.ToString());

            case ImageEntityType.AniDB_Creator:

                VM_AniDB_Seiyuu cre = req.ImageData as VM_AniDB_Seiyuu;
                return(cre.AniDB_SeiyuuID.ToString());

            default:
                return("");
            }
        }
        private string GetFileName(ImageDownloadRequest req, bool thumbNailOnly)
        {
            switch (req.ImageType)
            {
            case ImageEntityType.AniDB_Cover:

                VM_AniDB_Anime anime = req.ImageData as VM_AniDB_Anime;
                return(anime.PosterPathNoDefaultPlain);

            case ImageEntityType.TvDB_Cover:

                VM_TvDB_ImagePoster poster = req.ImageData as VM_TvDB_ImagePoster;
                return(poster.FullImagePathPlain);

            case ImageEntityType.TvDB_Banner:

                VM_TvDB_ImageWideBanner banner = req.ImageData as VM_TvDB_ImageWideBanner;
                return(banner.FullImagePathPlain);

            case ImageEntityType.TvDB_Episode:

                VM_TvDB_Episode episode = req.ImageData as VM_TvDB_Episode;
                return(episode.FullImagePathPlain);

            case ImageEntityType.TvDB_FanArt:

                VM_TvDB_ImageFanart fanart = req.ImageData as VM_TvDB_ImageFanart;

                if (thumbNailOnly)
                {
                    return(fanart.FullThumbnailPathPlain);
                }
                else
                {
                    return(fanart.FullImagePathPlain);
                }

            case ImageEntityType.MovieDB_Poster:

                VM_MovieDB_Poster moviePoster = req.ImageData as VM_MovieDB_Poster;
                return(moviePoster.FullImagePathPlain);

            case ImageEntityType.MovieDB_FanArt:

                VM_MovieDB_Fanart movieFanart = req.ImageData as VM_MovieDB_Fanart;
                return(movieFanart.FullImagePathPlain);

            case ImageEntityType.Trakt_Poster:

                VM_Trakt_ImagePoster traktPoster = req.ImageData as VM_Trakt_ImagePoster;
                return(traktPoster.FullImagePathPlain);

            case ImageEntityType.Trakt_Fanart:

                VM_Trakt_ImageFanart trakFanart = req.ImageData as VM_Trakt_ImageFanart;
                return(trakFanart.FullImagePathPlain);

            case ImageEntityType.Trakt_Episode:

                VM_Trakt_Episode trakEp = req.ImageData as VM_Trakt_Episode;
                return(trakEp.FullImagePathPlain);

            case ImageEntityType.AniDB_Character:

                VM_AniDB_Character chr = req.ImageData as VM_AniDB_Character;
                return(chr.ImagePathPlain);

            case ImageEntityType.AniDB_Creator:

                VM_AniDB_Seiyuu cre = req.ImageData as VM_AniDB_Seiyuu;
                return(cre.ImagePathPlain);

            default:
                return("");
            }
        }