void btnUpdate_Click(object sender, RoutedEventArgs e) { try { if (cboSeasonNumber.Items.Count == 0) { MessageBox.Show(JMMClient.Properties.Resources.TvDB_NoSeasons, JMMClient.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } AniDB_EpisodeVM aniEp = cboAniDBEpisodeNumber.SelectedItem as AniDB_EpisodeVM; if (aniEp == null) { MessageBox.Show(JMMClient.Properties.Resources.TvDB_NoAniDB, JMMClient.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } AnimeEpisodeNumber = aniEp.EpisodeNumber; TvDB_EpisodeVM tvep = cboEpisodeNumber.SelectedItem as TvDB_EpisodeVM; if (tvep == null) { MessageBox.Show(JMMClient.Properties.Resources.TvDB_NoTvDB, JMMClient.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } TvDBEpisodeNumber = tvep.EpisodeNumber; int aniEpType = (int)EpisodeType.Episode; if (cboEpisodeType.SelectedIndex == 1) { aniEpType = (int)EpisodeType.Special; } AnimeEpisodeType = aniEpType; TvDBSeason = int.Parse(cboSeasonNumber.SelectedItem.ToString()); this.Cursor = Cursors.Wait; string res = JMMServerVM.Instance.clientBinaryHTTP.LinkAniDBTvDB(AnimeID, AnimeEpisodeType, AnimeEpisodeNumber, TvDBID, TvDBSeason, TvDBEpisodeNumber, CrossRef_AniDB_TvDBV2ID); if (res.Length > 0) { MessageBox.Show(res, JMMClient.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } else { this.DialogResult = true; this.Close(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
private void CommandBinding_UseThis(object sender, ExecutedRoutedEventArgs e) { Window parentWindow = Window.GetWindow(this); object obj = e.Parameter; if (obj == null) { return; } try { if (obj.GetType() == typeof(TvDB_EpisodeVM)) { this.Cursor = Cursors.Wait; TvDB_EpisodeVM tvEp = obj as TvDB_EpisodeVM; string res = JMMServerVM.Instance.clientBinaryHTTP.LinkAniDBTvDBEpisode(AnimeEpisode.AniDB_EpisodeID, tvEp.Id, AnimeID); this.Cursor = Cursors.Arrow; if (res.Length > 0) { Utils.ShowErrorMessage(res); return; } this.DialogResult = true; this.Close(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { this.Cursor = Cursors.Arrow; } }
public void DownloadTvDBEpisode(TvDB_EpisodeVM episode, bool forceDownload) { if (string.IsNullOrEmpty(episode.Filename)) { return; } try { string url = string.Format(Constants.URLS.TvDB_Images, episode.Filename); string filename = episode.FullImagePath; ImageDownloadRequest req = new ImageDownloadRequest(ImageEntityType.TvDB_Episode, episode, 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(episode.FullImagePath)) { this.imagesToDownload.Enqueue(req); OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount)); return; } // the file exists so don't download it again return; } this.imagesToDownload.Enqueue(req); OnQueueUpdateEvent(new QueueUpdateEventArgs(this.QueueCount)); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private string GetEntityID(ImageDownloadRequest req) { switch (req.ImageType) { case ImageEntityType.AniDB_Cover: AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM; return(anime.AnimeID.ToString()); case ImageEntityType.TvDB_Cover: TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM; return(poster.TvDB_ImagePosterID.ToString()); case ImageEntityType.TvDB_Banner: TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM; return(banner.TvDB_ImageWideBannerID.ToString()); case ImageEntityType.TvDB_Episode: TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM; return(episode.TvDB_EpisodeID.ToString()); case ImageEntityType.TvDB_FanArt: TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM; return(fanart.TvDB_ImageFanartID.ToString()); case ImageEntityType.MovieDB_Poster: MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM; return(moviePoster.MovieDB_PosterID.ToString()); case ImageEntityType.MovieDB_FanArt: MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM; return(movieFanart.MovieDB_FanartID.ToString()); case ImageEntityType.Trakt_Poster: Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM; return(traktPoster.Trakt_ImagePosterID.ToString()); case ImageEntityType.Trakt_Fanart: Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM; return(trakFanart.Trakt_ImageFanartID.ToString()); case ImageEntityType.Trakt_CommentUser: Trakt_CommentUserVM traktShoutUser = req.ImageData as Trakt_CommentUserVM; return(traktShoutUser.User.Trakt_FriendID.ToString()); case ImageEntityType.Trakt_Episode: Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM; return(trakEp.Trakt_EpisodeID.ToString()); case ImageEntityType.AniDB_Character: AniDB_CharacterVM chr = req.ImageData as AniDB_CharacterVM; return(chr.AniDB_CharacterID.ToString()); case ImageEntityType.AniDB_Creator: AniDB_SeiyuuVM cre = req.ImageData as AniDB_SeiyuuVM; return(cre.AniDB_SeiyuuID.ToString()); default: return(""); } }
private string GetFileName(ImageDownloadRequest req, bool thumbNailOnly) { switch (req.ImageType) { case ImageEntityType.AniDB_Cover: AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM; return(anime.PosterPathNoDefaultPlain); case ImageEntityType.TvDB_Cover: TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM; return(poster.FullImagePathPlain); case ImageEntityType.TvDB_Banner: TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM; return(banner.FullImagePathPlain); case ImageEntityType.TvDB_Episode: TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM; return(episode.FullImagePathPlain); case ImageEntityType.TvDB_FanArt: TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM; if (thumbNailOnly) { return(fanart.FullThumbnailPathPlain); } else { return(fanart.FullImagePathPlain); } case ImageEntityType.MovieDB_Poster: MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM; return(moviePoster.FullImagePathPlain); case ImageEntityType.MovieDB_FanArt: MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM; return(movieFanart.FullImagePathPlain); case ImageEntityType.Trakt_Poster: Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM; return(traktPoster.FullImagePathPlain); case ImageEntityType.Trakt_Fanart: Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM; return(trakFanart.FullImagePathPlain); case ImageEntityType.Trakt_Episode: Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM; return(trakEp.FullImagePathPlain); case ImageEntityType.AniDB_Character: AniDB_CharacterVM chr = req.ImageData as AniDB_CharacterVM; return(chr.ImagePathPlain); case ImageEntityType.AniDB_Creator: AniDB_SeiyuuVM cre = req.ImageData as AniDB_SeiyuuVM; return(cre.ImagePathPlain); default: return(""); } }
private string GetEntityID(ImageDownloadRequest req) { switch (req.ImageType) { case ImageEntityType.AniDB_Cover: AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM; return(anime.AnimeID.ToString()); case ImageEntityType.TvDB_Cover: TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM; return(poster.TvDB_ImagePosterID.ToString()); case ImageEntityType.TvDB_Banner: TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM; return(banner.TvDB_ImageWideBannerID.ToString()); case ImageEntityType.TvDB_Episode: TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM; return(episode.TvDB_EpisodeID.ToString()); case ImageEntityType.TvDB_FanArt: TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM; return(fanart.TvDB_ImageFanartID.ToString()); case ImageEntityType.MovieDB_Poster: MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM; return(moviePoster.MovieDB_PosterID.ToString()); case ImageEntityType.MovieDB_FanArt: MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM; return(movieFanart.MovieDB_FanartID.ToString()); case ImageEntityType.Trakt_Poster: Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM; return(traktPoster.Trakt_ImagePosterID.ToString()); case ImageEntityType.Trakt_Fanart: Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM; return(trakFanart.Trakt_ImageFanartID.ToString()); case ImageEntityType.Trakt_Friend: Trakt_FriendVM trakFriend = req.ImageData as Trakt_FriendVM; return(trakFriend.Trakt_FriendID.ToString()); case ImageEntityType.Trakt_ActivityScrobble: Trakt_ActivityScrobbleVM trakScrobble = req.ImageData as Trakt_ActivityScrobbleVM; return(trakScrobble.User.Trakt_FriendID.ToString()); case ImageEntityType.Trakt_ShoutUser: Trakt_ShoutUserVM traktShoutUser = req.ImageData as Trakt_ShoutUserVM; return(traktShoutUser.User.Trakt_FriendID.ToString()); case ImageEntityType.Trakt_Episode: Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM; return(trakEp.Trakt_EpisodeID.ToString()); case ImageEntityType.Trakt_WatchedEpisode: Trakt_WatchedEpisodeVM trakwEp = req.ImageData as Trakt_WatchedEpisodeVM; return(trakwEp.Trakt_EpisodeID.ToString()); default: return(""); } }
private string GetFileName(ImageDownloadRequest req, bool thumbNailOnly) { switch (req.ImageType) { case ImageEntityType.AniDB_Cover: AniDB_AnimeVM anime = req.ImageData as AniDB_AnimeVM; return(anime.PosterPathNoDefaultPlain); case ImageEntityType.TvDB_Cover: TvDB_ImagePosterVM poster = req.ImageData as TvDB_ImagePosterVM; return(poster.FullImagePathPlain); case ImageEntityType.TvDB_Banner: TvDB_ImageWideBannerVM banner = req.ImageData as TvDB_ImageWideBannerVM; return(banner.FullImagePathPlain); case ImageEntityType.TvDB_Episode: TvDB_EpisodeVM episode = req.ImageData as TvDB_EpisodeVM; return(episode.FullImagePathPlain); case ImageEntityType.TvDB_FanArt: TvDB_ImageFanartVM fanart = req.ImageData as TvDB_ImageFanartVM; if (thumbNailOnly) { return(fanart.FullThumbnailPathPlain); } else { return(fanart.FullImagePathPlain); } case ImageEntityType.MovieDB_Poster: MovieDB_PosterVM moviePoster = req.ImageData as MovieDB_PosterVM; return(moviePoster.FullImagePathPlain); case ImageEntityType.MovieDB_FanArt: MovieDB_FanartVM movieFanart = req.ImageData as MovieDB_FanartVM; return(movieFanart.FullImagePathPlain); case ImageEntityType.Trakt_Poster: Trakt_ImagePosterVM traktPoster = req.ImageData as Trakt_ImagePosterVM; return(traktPoster.FullImagePathPlain); case ImageEntityType.Trakt_Fanart: Trakt_ImageFanartVM trakFanart = req.ImageData as Trakt_ImageFanartVM; return(trakFanart.FullImagePathPlain); case ImageEntityType.Trakt_Friend: Trakt_FriendVM trakFriend = req.ImageData as Trakt_FriendVM; return(trakFriend.FullImagePathPlain); case ImageEntityType.Trakt_ActivityScrobble: Trakt_ActivityScrobbleVM trakScrobble = req.ImageData as Trakt_ActivityScrobbleVM; return(trakScrobble.UserFullImagePathPlain); case ImageEntityType.Trakt_ShoutUser: Trakt_ShoutUserVM trakShoutUser = req.ImageData as Trakt_ShoutUserVM; return(trakShoutUser.UserFullImagePathPlain); case ImageEntityType.Trakt_Episode: Trakt_EpisodeVM trakEp = req.ImageData as Trakt_EpisodeVM; return(trakEp.FullImagePathPlain); case ImageEntityType.Trakt_WatchedEpisode: Trakt_WatchedEpisodeVM trakwEp = req.ImageData as Trakt_WatchedEpisodeVM; return(trakwEp.FullImagePathPlain); default: return(""); } }
void cboEpisodeNumber_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedEpisode = cboEpisodeNumber.SelectedItem as TvDB_EpisodeVM; }
/// <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 }