public void RefreshFilesForEpisode() { try { filesForEpisode = new List <VideoDetailedVM>(); List <JMMServerBinary.Contract_VideoDetailed> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetFilesForEpisode(AnimeEpisodeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_VideoDetailed fi in contracts) { filesForEpisode.Add(new VideoDetailedVM(fi)); } List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("OverallVideoSourceRanking", true, JMMClient.SortType.eInteger)); filesForEpisode = Sorting.MultiSort <VideoDetailedVM>(filesForEpisode, sortCriteria); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public List <VideoLocalVM> GetAllVideoLocals() { List <VideoLocalVM> vids = new List <VideoLocalVM>(); try { List <JMMServerBinary.Contract_VideoLocal> contracts = JMMServerVM.Instance.clientBinaryHTTP.GetVideoLocalsForEpisode(AnimeEpisodeID, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); foreach (JMMServerBinary.Contract_VideoLocal fi in contracts) { vids.Add(new VideoLocalVM(fi)); } List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("FilePath", false, JMMClient.SortType.eString)); vids = Sorting.MultiSort <VideoLocalVM>(vids, sortCriteria); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } return(vids); }
/// <summary> /// Set the Episode image and overview, also over-write the episode name if user has selected this /// </summary> /// <param name="dictTvDBEpisodes"></param> /// <param name="dictTvDBSeasons"></param> /// <param name="dictTvDBSeasonsSpecials"></param> /// <param name="tvDBCrossRef"></param> public void SetTvDBInfo(TvDBSummary tvSummary) { TvDBLinkExists = false; TvDBLinkMissing = true; #region episode override // check if this episode has a direct tvdb over-ride if (tvSummary.DictTvDBCrossRefEpisodes.ContainsKey(AniDB_EpisodeID)) { foreach (TvDB_EpisodeVM tvep in tvSummary.DictTvDBEpisodes.Values) { if (tvSummary.DictTvDBCrossRefEpisodes[AniDB_EpisodeID] == tvep.Id) { if (string.IsNullOrEmpty(tvep.Overview)) { this.EpisodeOverviewLoading = "Episode Overview Not Available"; } else { this.EpisodeOverviewLoading = tvep.Overview; } if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } TvDBLinkExists = true; TvDBLinkMissing = false; return; } } } #endregion //logger.Trace("SetTvDBInfo: normal episodes start"); #region normal episodes // now do stuff to improve performance if (this.EpisodeTypeEnum == JMMClient.EpisodeType.Episode) { if (tvSummary != null && tvSummary.CrossRefTvDBV2 != null && tvSummary.CrossRefTvDBV2.Count > 0) { //logger.Trace("SetTvDBInfo: sorting TvDB cross refs: {0} records", tvSummary.CrossRefTvDBV2.Count); // find the xref that is right // relies on the xref's being sorted by season number and then episode number (desc) List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("AniDBStartEpisodeNumber", true, JMMClient.SortType.eInteger)); List <CrossRef_AniDB_TvDBVMV2> tvDBCrossRef = Sorting.MultiSort <CrossRef_AniDB_TvDBVMV2>(tvSummary.CrossRefTvDBV2, sortCriteria); //logger.Trace("SetTvDBInfo: looking for starting points"); bool foundStartingPoint = false; CrossRef_AniDB_TvDBVMV2 xrefBase = null; foreach (CrossRef_AniDB_TvDBVMV2 xrefTV in tvDBCrossRef) { if (xrefTV.AniDBStartEpisodeType != (int)JMMClient.EpisodeType.Episode) { continue; } if (this.EpisodeNumber >= xrefTV.AniDBStartEpisodeNumber) { foundStartingPoint = true; xrefBase = xrefTV; break; } } //logger.Trace("SetTvDBInfo: looking for starting points - done"); // we have found the starting epiosde numbder from AniDB // now let's check that the TvDB Season and Episode Number exist if (foundStartingPoint) { //logger.Trace("SetTvDBInfo: creating dictionary"); Dictionary <int, int> dictTvDBSeasons = null; Dictionary <int, TvDB_EpisodeVM> dictTvDBEpisodes = null; foreach (TvDBDetails det in tvSummary.TvDetails.Values) { if (det.TvDBID == xrefBase.TvDBID) { dictTvDBSeasons = det.DictTvDBSeasons; dictTvDBEpisodes = det.DictTvDBEpisodes; break; } } //logger.Trace("SetTvDBInfo: creating dictionary - done"); if (dictTvDBSeasons.ContainsKey(xrefBase.TvDBSeasonNumber)) { int episodeNumber = dictTvDBSeasons[xrefBase.TvDBSeasonNumber] + (this.EpisodeNumber + xrefBase.TvDBStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1); if (dictTvDBEpisodes.ContainsKey(episodeNumber)) { //logger.Trace("SetTvDBInfo: loading episode overview"); TvDB_EpisodeVM tvep = dictTvDBEpisodes[episodeNumber]; if (string.IsNullOrEmpty(tvep.Overview)) { this.EpisodeOverviewLoading = "Episode Overview Not Available"; } else { this.EpisodeOverviewLoading = tvep.Overview; } //logger.Trace("SetTvDBInfo: loading episode overview - done"); if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } //logger.Trace("SetTvDBInfo: episode image - done"); if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } } } } } } #endregion //logger.Trace("SetTvDBInfo: normal episodes finish"); #region special episodes if (this.EpisodeTypeEnum == JMMClient.EpisodeType.Special) { // find the xref that is right // relies on the xref's being sorted by season number and then episode number (desc) List <SortPropOrFieldAndDirection> sortCriteria = new List <SortPropOrFieldAndDirection>(); sortCriteria.Add(new SortPropOrFieldAndDirection("AniDBStartEpisodeNumber", true, JMMClient.SortType.eInteger)); List <CrossRef_AniDB_TvDBVMV2> tvDBCrossRef = Sorting.MultiSort <CrossRef_AniDB_TvDBVMV2>(tvSummary.CrossRefTvDBV2, sortCriteria); bool foundStartingPoint = false; CrossRef_AniDB_TvDBVMV2 xrefBase = null; foreach (CrossRef_AniDB_TvDBVMV2 xrefTV in tvDBCrossRef) { if (xrefTV.AniDBStartEpisodeType != (int)JMMClient.EpisodeType.Special) { continue; } if (this.EpisodeNumber >= xrefTV.AniDBStartEpisodeNumber) { foundStartingPoint = true; xrefBase = xrefTV; break; } } if (tvSummary != null && tvSummary.CrossRefTvDBV2 != null && tvSummary.CrossRefTvDBV2.Count > 0) { // we have found the starting epiosde numbder from AniDB // now let's check that the TvDB Season and Episode Number exist if (foundStartingPoint) { Dictionary <int, int> dictTvDBSeasons = null; Dictionary <int, TvDB_EpisodeVM> dictTvDBEpisodes = null; foreach (TvDBDetails det in tvSummary.TvDetails.Values) { if (det.TvDBID == xrefBase.TvDBID) { dictTvDBSeasons = det.DictTvDBSeasons; dictTvDBEpisodes = det.DictTvDBEpisodes; break; } } if (dictTvDBSeasons.ContainsKey(xrefBase.TvDBSeasonNumber)) { int episodeNumber = dictTvDBSeasons[xrefBase.TvDBSeasonNumber] + (this.EpisodeNumber + xrefBase.TvDBStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1); if (dictTvDBEpisodes.ContainsKey(episodeNumber)) { TvDB_EpisodeVM tvep = dictTvDBEpisodes[episodeNumber]; this.EpisodeOverviewLoading = tvep.Overview; if (string.IsNullOrEmpty(tvep.FullImagePathPlain) || !File.Exists(tvep.FullImagePath)) { this.EpisodeImageLoading = @"/Images/EpisodeThumb_NotFound.png"; // if there is no proper image to show, we will hide it on the dashboard ShowEpisodeImageInDashboard = false; } else { this.EpisodeImageLoading = tvep.FullImagePath; } if (JMMServerVM.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(tvep.EpisodeName)) { EpisodeName = tvep.EpisodeName; } } } } } } #endregion }