private static void PopulateVideoEpisodeFromAnimeEpisode(Video v, AnimeEpisode ep, int userid) { AniDB_Episode aep = ep.AniDB_Episode; if (aep != null) { v.EpNumber = aep.EpisodeNumber; v.Index = aep.EpisodeNumber.ToString(); v.Title = aep.EnglishName; v.OriginalTitle = aep.RomajiName; v.Rating = (float.Parse(aep.Rating, CultureInfo.InvariantCulture)).ToString(CultureInfo.InvariantCulture); if (aep.AirDateAsDate.HasValue) { v.Year = aep.AirDateAsDate.Value.Year.ToString(); v.OriginallyAvailableAt = aep.AirDateAsDate.Value.ToPlexDate(); } AnimeEpisode_User epuser = ep.GetUserRecord(userid); if (epuser != null) { v.ViewCount = epuser.WatchedCount.ToString(); if (epuser.WatchedDate.HasValue) { v.LastViewedAt = epuser.WatchedDate.Value.ToUnixTime(); } } MetroContract_Anime_Episode contract = new MetroContract_Anime_Episode(); JMMServiceImplementationMetro.SetTvDBInfo(aep.AnimeID, aep, ref contract); v.Thumb = contract.GenPoster(); v.Summary = contract.EpisodeOverview; } }
public static Video GenerateVideoFromAnimeEpisode(AnimeEpisode ep) { Video l = new Video(); List <VideoLocal> vids = ep.GetVideoLocals(); l.Type = "episode"; l.Summary = "Episode Overview Not Available"; //TODO Intenationalization l.Id = ep.AnimeEpisodeID.ToString(); l.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimeEpisode.ToString(); VideoLocalRepository repo = new VideoLocalRepository(); if (vids.Count > 0) { l.Title = Path.GetFileNameWithoutExtension(vids[0].FilePath); l.AddedAt = vids[0].DateTimeCreated.ToUnixTime(); l.UpdatedAt = vids[0].DateTimeUpdated.ToUnixTime(); l.OriginallyAvailableAt = vids[0].DateTimeCreated.ToPlexDate(); l.Year = vids[0].DateTimeCreated.Year.ToString(); l.Medias = new List <Media>(); foreach (VideoLocal v in vids) { Media m = v.Media; if (m == null) { if (File.Exists(v.FullServerPath)) { repo.Save(v, false); } } if (m != null) { l.Medias.Add(m); l.Duration = m.Duration; } } } AniDB_Episode aep = ep?.AniDB_Episode; if (aep != null) { l.EpisodeNumber = aep.EpisodeNumber.ToString(); l.Index = aep.EpisodeNumber.ToString(); l.Title = aep.EnglishName; l.OriginalTitle = aep.RomajiName; l.EpisodeType = aep.EpisodeType.ToString(); l.Rating = float.Parse(aep.Rating, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); if (aep.AirDateAsDate.HasValue) { l.Year = aep.AirDateAsDate.Value.Year.ToString(); l.OriginallyAvailableAt = aep.AirDateAsDate.Value.ToPlexDate(); } //FIX THIS MetroContract_Anime_Episode contract = new MetroContract_Anime_Episode(); JMMServiceImplementationMetro.SetTvDBInfo(aep.AnimeID, aep, ref contract); l.Thumb = contract.GenPoster(); l.Summary = contract.EpisodeOverview; } l.Id = ep.AnimeEpisodeID.ToString(); return(l); }
public static Video GenerateVideoFromAnimeEpisode(AnimeEpisode ep) { Video l = new Video(); List <VideoLocal> vids = ep.GetVideoLocals(); l.Type = "episode"; l.Summary = "Episode Overview Not Available"; //TODO Intenationalization l.Id = ep.AnimeEpisodeID.ToString(); l.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimeEpisode.ToString(); if (vids.Count > 0) { //List<string> hashes = vids.Select(a => a.Hash).Distinct().ToList(); l.Title = Path.GetFileNameWithoutExtension(vids[0].FileName); l.AddedAt = vids[0].DateTimeCreated.ToUnixTime(); l.UpdatedAt = vids[0].DateTimeUpdated.ToUnixTime(); l.OriginallyAvailableAt = vids[0].DateTimeCreated.ToPlexDate(); l.Year = vids[0].DateTimeCreated.Year.ToString(); l.Medias = new List <Media>(); foreach (VideoLocal v in vids) { if (string.IsNullOrEmpty(v.Media?.Duration)) { VideoLocal_Place pl = v.GetBestVideoLocalPlace(); if (pl != null) { if (pl.RefreshMediaInfo()) { RepoFactory.VideoLocal.Save(v, true); } } } if (v.Media != null) { l.Medias.Add(v.Media); } } } AniDB_Episode aep = ep?.AniDB_Episode; if (aep != null) { l.EpisodeNumber = aep.EpisodeNumber.ToString(); l.Index = aep.EpisodeNumber.ToString(); l.Title = aep.EnglishName; l.OriginalTitle = aep.RomajiName; l.EpisodeType = aep.EpisodeType.ToString(); l.Rating = float.Parse(aep.Rating, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); if (aep.AirDateAsDate.HasValue) { l.Year = aep.AirDateAsDate.Value.Year.ToString(); l.OriginallyAvailableAt = aep.AirDateAsDate.Value.ToPlexDate(); } //FIX THIS MetroContract_Anime_Episode contract = new MetroContract_Anime_Episode(); JMMServiceImplementationMetro.SetTvDBInfo(aep.AnimeID, aep, ref contract); l.Thumb = contract.GenPoster(); l.Summary = contract.EpisodeOverview; } l.Id = ep.AnimeEpisodeID.ToString(); return(l); }