예제 #1
0
        public static Metro_AniDB_Character ToContractMetro(this AniDB_Character character, ISession session,
                                                            AniDB_Anime_Character charRel)
        {
            Metro_AniDB_Character contract = new Metro_AniDB_Character
            {
                AniDB_CharacterID = character.AniDB_CharacterID,
                CharID            = character.CharID,
                CharName          = character.CharName,
                CharKanjiName     = character.CharKanjiName,
                CharDescription   = character.CharDescription,

                CharType = charRel.CharType,

                ImageType = (int)ImageEntityType.AniDB_Character,
                ImageID   = character.AniDB_CharacterID
            };
            AniDB_Seiyuu seiyuu = character.GetSeiyuu(session);

            if (seiyuu != null)
            {
                contract.SeiyuuID        = seiyuu.AniDB_SeiyuuID;
                contract.SeiyuuName      = seiyuu.SeiyuuName;
                contract.SeiyuuImageType = (int)ImageEntityType.AniDB_Creator;
                contract.SeiyuuImageID   = seiyuu.AniDB_SeiyuuID;
            }

            return(contract);
        }
예제 #2
0
 public static AniDB_Seiyuu GetSeiyuu(this AniDB_Character character)
 {
     using (var session = DatabaseFactory.SessionFactory.OpenSession())
     {
         return(character.GetSeiyuu(session));
     }
 }
예제 #3
0
        public static Azure_AnimeCharacter ToContractAzure(this AniDB_Character character,
                                                           AniDB_Anime_Character charRel)
        {
            Azure_AnimeCharacter contract = new Azure_AnimeCharacter
            {
                CharID          = character.CharID,
                CharName        = character.CharName,
                CharKanjiName   = character.CharKanjiName,
                CharDescription = character.CharDescription,
                CharType        = charRel.CharType,
                CharImageURL    = string.Format(Constants.URLS.AniDB_Images, character.PicName)
            };
            AniDB_Seiyuu seiyuu = character.GetSeiyuu();

            if (seiyuu != null)
            {
                contract.SeiyuuID       = seiyuu.AniDB_SeiyuuID;
                contract.SeiyuuName     = seiyuu.SeiyuuName;
                contract.SeiyuuImageURL = string.Format(Constants.URLS.AniDB_Images, seiyuu.PicName);
            }

            return(contract);
        }
예제 #4
0
        public static CL_AniDB_Character ToClient(this AniDB_Character character, string charType)
        {
            AniDB_Seiyuu seiyuu = character.GetSeiyuu();

            return(character.ToClient(charType, seiyuu));
        }
예제 #5
0
        private AniDB_Anime SaveResultsForAnimeXML(ISession session, int animeID, bool downloadRelations, AniDBHTTPCommand_GetFullAnime getAnimeCmd)
        {
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            AniDB_Anime           anime    = null;

            logger.Trace("cmdResult.Anime: {0}", getAnimeCmd.Anime);

            anime = repAnime.GetByAnimeID(session, animeID);
            if (anime == null)
            {
                anime = new AniDB_Anime();
            }
            anime.PopulateAndSaveFromHTTP(session, getAnimeCmd.Anime, getAnimeCmd.Episodes, getAnimeCmd.Titles, getAnimeCmd.Categories, getAnimeCmd.Tags,
                                          getAnimeCmd.Characters, getAnimeCmd.Relations, getAnimeCmd.SimilarAnime, getAnimeCmd.Recommendations, downloadRelations);

            // Request an image download
            CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(anime.AniDB_AnimeID, JMMImageType.AniDB_Cover, false);

            cmd.Save(session);
            // create AnimeEpisode records for all episodes in this anime
            // only if we have a series
            AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
            AnimeSeries           ser       = repSeries.GetByAnimeID(session, animeID);

            if (ser != null)
            {
                ser.CreateAnimeEpisodes(session);
            }

            // update any files, that may have been linked

            /*CrossRef_File_EpisodeRepository repCrossRefs = new CrossRef_File_EpisodeRepository();
             * repCrossRefs.GetByAnimeID(*/

            // update cached stats
            StatsCache.Instance.UpdateUsingAnime(session, anime.AnimeID);
            StatsCache.Instance.UpdateAnimeContract(session, anime.AnimeID);

            // download character images
            foreach (AniDB_Anime_Character animeChar in anime.GetAnimeCharacters(session))
            {
                AniDB_Character chr = animeChar.GetCharacter(session);
                if (chr == null)
                {
                    continue;
                }

                if (ServerSettings.AniDB_DownloadCharacters)
                {
                    if (!string.IsNullOrEmpty(chr.PosterPath) && !File.Exists(chr.PosterPath))
                    {
                        logger.Debug("Downloading character image: {0} - {1}({2}) - {3}", anime.MainTitle, chr.CharName, chr.CharID, chr.PosterPath);
                        cmd = new CommandRequest_DownloadImage(chr.AniDB_CharacterID, JMMImageType.AniDB_Character, false);
                        cmd.Save();
                    }
                }

                if (ServerSettings.AniDB_DownloadCreators)
                {
                    AniDB_Seiyuu seiyuu = chr.GetSeiyuu(session);
                    if (seiyuu == null || string.IsNullOrEmpty(seiyuu.PosterPath))
                    {
                        continue;
                    }

                    if (!File.Exists(seiyuu.PosterPath))
                    {
                        logger.Debug("Downloading seiyuu image: {0} - {1}({2}) - {3}", anime.MainTitle, seiyuu.SeiyuuName, seiyuu.SeiyuuID, seiyuu.PosterPath);
                        cmd = new CommandRequest_DownloadImage(seiyuu.AniDB_SeiyuuID, JMMImageType.AniDB_Creator, false);
                        cmd.Save();
                    }
                }
            }

            return(anime);
        }
예제 #6
0
        public static void FillSerie(Video p, AnimeSeries aser, AniDB_Anime anidb, Contract_AnimeSeries ser, int userid)
        {
            using (ISession session = JMMService.SessionFactory.OpenSession())
            {
                Contract_AniDBAnime anime = ser.AniDBAnime;
                p.Key = ConstructSerieIdUrl(userid, ser.AnimeSeriesID.ToString());
                if (ser.AniDBAnime.Restricted > 0)
                {
                    p.ContentRating = "R";
                }
                p.Title   = aser.GetSeriesName(session);
                p.Summary = SummaryFromAnimeContract(ser);
                p.Type    = "show";
                p.AirDate = DateTime.MinValue;
                TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                if (!string.IsNullOrEmpty(anime.AllTags))
                {
                    p.Genres = new List <Tag>();
                    anime.AllTags.Split('|').ToList().ForEach(a => p.Genres.Add(new Tag {
                        Value = textInfo.ToTitleCase(a.Trim())
                    }));
                }
                //p.OriginalTitle
                if (anime.AirDate.HasValue)
                {
                    p.AirDate = anime.AirDate.Value;
                    p.OriginallyAvailableAt = anime.AirDate.Value.ToPlexDate();
                    p.Year = anime.AirDate.Value.Year.ToString();
                }
                p.LeafCount = anime.EpisodeCount.ToString();
                //p.ChildCount = p.LeafCount;
                p.ViewedLeafCount = ser.WatchedEpisodeCount.ToString();
                p.Rating          = (anime.Rating / 100F).ToString(CultureInfo.InvariantCulture);
                List <Contract_CrossRef_AniDB_TvDBV2> ls = ser.CrossRefAniDBTvDBV2;
                if (ls != null && ls.Count > 0)
                {
                    foreach (Contract_CrossRef_AniDB_TvDBV2 c in ls)
                    {
                        if (c.TvDBSeasonNumber != 0)
                        {
                            p.Season = c.TvDBSeasonNumber.ToString();
                            p.Index  = p.Season;
                        }
                    }
                }
                p.Thumb = anime.DefaultImagePoster.GenPoster();
                p.Art   = anime.DefaultImageFanart.GenArt();
                List <AniDB_Anime_Character> chars = anidb.GetAnimeCharacters(session);

                p.Roles = new List <Tag>();
                if (chars != null)
                {
                    foreach (AniDB_Anime_Character c in chars)
                    {
                        AniDB_Character cha    = c.GetCharacter(session);
                        AniDB_Seiyuu    seiyuu = cha?.GetSeiyuu(session);
                        if (seiyuu != null)
                        {
                            p.Roles.Add(new Tag
                            {
                                Value = seiyuu.SeiyuuName,
                                Role  = cha.CharName
                            });
                        }
                    }
                }
            }
        }