コード例 #1
0
ファイル: KodiHelper.cs プロジェクト: Zhardas/jmmserver
        internal static Directory FromGroup(Contract_AnimeGroup grp, Contract_AnimeSeries ser, int userid)
        {
            Directory p = new Directory();

            p.Key = ServerUrl(int.Parse(ServerSettings.JMMServerPort),
                              MainWindow.PathAddressKodi + "/GetMetadata/" + userid + "/" + (int)JMMType.Group + "/" +
                              grp.AnimeGroupID.ToString());
            p.Title   = grp.GroupName;
            p.Summary = grp.Description;
            p.Type    = "show";
            p.AirDate = grp.Stat_AirDate_Min.HasValue ? grp.Stat_AirDate_Min.Value : DateTime.MinValue;
            Contract_AniDBAnime anime = ser.AniDBAnime;

            if (anime != null)
            {
                Contract_AniDB_Anime_DefaultImage poster = anime.DefaultImagePoster;
                Contract_AniDB_Anime_DefaultImage fanart = anime.DefaultImageFanart;
                p.Thumb = poster != null?poster.GenPoster() : ServerUrl(int.Parse(ServerSettings.JMMServerPort), MainWindow.PathAddressKodi + "/GetSupportImage/plex_404V.png");

                if (fanart != null)
                {
                    p.Art = fanart.GenArt();
                }
            }
            p.LeafCount       = (grp.UnwatchedEpisodeCount + grp.WatchedEpisodeCount).ToString();
            p.ViewedLeafCount = grp.WatchedEpisodeCount.ToString();
            return(p);
        }
コード例 #2
0
ファイル: KodiHelper.cs プロジェクト: Zhardas/jmmserver
        public static Directory FromSerie(Contract_AnimeSeries ser, int userid)
        {
            Directory p = new Directory();

            Contract_AniDBAnime anime = ser.AniDBAnime;

            p.Key = ServerUrl(int.Parse(ServerSettings.JMMServerPort),
                              MainWindow.PathAddressKodi + "/GetMetadata/" + userid + "/" + (int)JMMType.Serie + "/" +
                              ser.AnimeSeriesID);

            if (ser.AniDBAnime.Restricted > 0)
            {
                p.ContentRating = "R";
            }
            p.Title   = anime.MainTitle;
            p.Summary = anime.Description;
            if (string.IsNullOrEmpty(p.Summary) && ser.MovieDB_Movie != null)
            {
                p.Summary = ser.MovieDB_Movie.Overview;
            }
            if (string.IsNullOrEmpty(p.Summary) && ser.TvDB_Series != null && ser.TvDB_Series.Count > 0)
            {
                p.Summary = ser.TvDB_Series[0].Overview;
            }
            p.Type    = "season";
            p.AirDate = DateTime.MinValue;

            if (!string.IsNullOrEmpty(anime.AllCategories))
            {
                p.Genres = new List <Tag> {
                    new Tag {
                        Value = anime.AllCategories.Replace("|", ",")
                    }
                };
            }
            if (!string.IsNullOrEmpty(anime.AllTags))
            {
                p.Tags = new List <Tag> {
                    new Tag {
                        Value = anime.AllTags.Replace("|", ",")
                    }
                };
            }
            p.OriginalTitle = anime.AllTitles;
            if (anime.AirDate.HasValue)
            {
                p.AirDate = anime.AirDate.Value;
                p.OriginallyAvailableAt = anime.AirDate.Value.Year.ToString("0000") + "-" + anime.AirDate.Value.Month.ToString("00") + "-" +
                                          anime.AirDate.Value.Day.ToString("00");
                p.Year = anime.AirDate.Value.Year.ToString();
            }
            p.LeafCount       = anime.EpisodeCount.ToString();
            p.ViewedLeafCount = ser.WatchedEpisodeCount.ToString();
            p.Rating          = (anime.Rating / 100F).ToString(CultureInfo.InvariantCulture);
            p.Votes           = anime.VoteCount.ToString();
            List <Contract_CrossRef_AniDB_TvDBV2> ls = ser.CrossRefAniDBTvDBV2;

            if (ls.Count > 0)
            {
                foreach (Contract_CrossRef_AniDB_TvDBV2 c in ls)
                {
                    if (c.TvDBSeasonNumber != 0)
                    {
                        p.Season = c.TvDBSeasonNumber.ToString();
                    }
                }
            }
            Contract_AniDB_Anime_DefaultImage poster = anime.DefaultImagePoster;
            Contract_AniDB_Anime_DefaultImage fanart = anime.DefaultImageFanart;

            p.Thumb = poster != null?poster.GenPoster() : ServerUrl(int.Parse(ServerSettings.JMMServerPort), MainWindow.PathAddressKodi + "/GetSupportImage/plex_404V.png");

            if (fanart != null)
            {
                p.Art = fanart.GenArt();
            }


            /*
             *  List<AniDB_Anime_Character> chars = anime.GetAnimeCharacters(session);
             *
             *  List<string> sey=new List<string>();
             *
             *  if (chars != null)
             *  {
             *      foreach (AniDB_Anime_Character c in chars)
             *      {
             *          AniDB_Character cha = c.GetCharacter(session);
             *          if (cha != null)
             *          {
             *              AniDB_Seiyuu seiyuu = cha.GetSeiyuu(session);
             *              if (seiyuu!=null)
             *                  sey.Add(seiyuu.SeiyuuName);
             *          }
             *      }
             *  }
             *  if (sey.Count > 0)
             *      p.Roles = sey.Select(a => new Tag() {Value = a}).ToList();
             */

            //community support

            //CrossRef_AniDB_TraktV2Repository repCrossRef = new CrossRef_AniDB_TraktV2Repository();
            //List<CrossRef_AniDB_TraktV2> Trakt = repCrossRef.GetByAnimeID(anime.AnimeID);
            //if (Trakt != null)
            //{
            //    if (Trakt.Count > 0)
            //    {
            //        p.Trakt = Trakt[0].TraktID;
            //    }
            //}

            //CrossRef_AniDB_TvDBV2Repository repCrossRefV2 = new CrossRef_AniDB_TvDBV2Repository();
            //List<CrossRef_AniDB_TvDBV2> TvDB = repCrossRefV2.GetByAnimeID(anime.AnimeID);
            //if (TvDB != null)
            //{
            //    if (TvDB.Count > 0)
            //    {
            //        p.TvDB = TvDB[0].TvDBID.ToString();
            //    }
            //}

            //community support END


            return(p);
        }