public void SetTraktInfo()
        {
            //this.RefreshAnime();

            VM_TraktSummary tvSummary = AniDB_Anime.traktSummary;

            SetTraktInfo(tvSummary);
        }
        public void SetTraktInfo(VM_TraktSummary traktSummary)
        {
            TraktLinkExists  = false;
            TraktLinkMissing = true;

            #region episode override
            // check if this episode has a direct tvdb over-ride

            /*if (traktSummary.DictTraktCrossRefEpisodes.ContainsKey(AniDB_EpisodeID))
             * {
             *  foreach (Trakt_EpisodeVM traktEp in traktSummary.DictTraktEpisodes.Values)
             *  {
             *      if (traktSummary.DictTraktCrossRefEpisodes[AniDB_EpisodeID] == traktEp.Id)
             *      {
             *          if (string.IsNullOrEmpty(traktEp.Overview))
             *              this.EpisodeOverviewLoading = "Episode Overview Not Available";
             *          else
             *              this.EpisodeOverviewLoading = traktEp.Overview;
             *
             *          if (string.IsNullOrEmpty(traktEp.FullImagePathPlain) || !File.Exists(traktEp.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 = traktEp.FullImagePath;
             *
             *          if (VM_ShokoServer.Instance.EpisodeTitleSource == DataSourceType.TheTvDB && !string.IsNullOrEmpty(traktEp.EpisodeName))
             *              EpisodeName = traktEp.EpisodeName;
             *
             *          TvDBLinkExists = true;
             *          TvDBLinkMissing = false;
             *
             *          return;
             *      }
             *  }
             * }*/
            #endregion

            //logger.Trace("SetTvDBInfo: normal episodes start");

            #region normal episodes
            // now do stuff to improve performance
            if (EpisodeTypeEnum == enEpisodeType.Episode)
            {
                if (traktSummary?.CrossRefTraktV2 != null && traktSummary.CrossRefTraktV2.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 <VM_CrossRef_AniDB_TraktV2> traktCrossRefs = traktSummary.CrossRefTraktV2.OrderByDescending(a => a.AniDBStartEpisodeNumber).ToList();

                    //logger.Trace("SetTvDBInfo: looking for starting points");

                    bool foundStartingPoint            = false;
                    VM_CrossRef_AniDB_TraktV2 xrefBase = null;
                    foreach (VM_CrossRef_AniDB_TraktV2 xrefTV in traktCrossRefs)
                    {
                        if (xrefTV.AniDBStartEpisodeType != (int)enEpisodeType.Episode)
                        {
                            continue;
                        }
                        if (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> dictTraktSeasons = null;
                        Dictionary <int, VM_Trakt_Episode> dictTraktEpisodes = null;
                        foreach (VM_TraktDetails det in traktSummary.traktDetails.Values)
                        {
                            if (det.TraktID.Equals(xrefBase.TraktID, StringComparison.InvariantCultureIgnoreCase))
                            {
                                dictTraktSeasons  = det.DictTraktSeasons;
                                dictTraktEpisodes = det.DictTraktEpisodes;
                                break;
                            }
                        }

                        //logger.Trace("SetTvDBInfo: creating dictionary - done");

                        if (dictTraktSeasons != null && dictTraktSeasons.ContainsKey(xrefBase.TraktSeasonNumber))
                        {
                            int episodeNumber = dictTraktSeasons[xrefBase.TraktSeasonNumber] + (EpisodeNumber + xrefBase.TraktStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1);
                            if (dictTraktEpisodes.ContainsKey(episodeNumber))
                            {
                                //logger.Trace("SetTvDBInfo: loading episode overview");
                                VM_Trakt_Episode traktEp = dictTraktEpisodes[episodeNumber];
                                TraktLinkExists  = true;
                                TraktLinkMissing = false;

                                TraktEpisodeURL = traktEp.URL;
                            }
                        }
                    }
                }
            }
            #endregion

            //logger.Trace("SetTvDBInfo: normal episodes finish");

            #region special episodes
            if (EpisodeTypeEnum == enEpisodeType.Special)
            {
                // find the xref that is right
                // relies on the xref's being sorted by season number and then episode number (desc)
                if (traktSummary != null)
                {
                    List <VM_CrossRef_AniDB_TraktV2> traktCrossRef = traktSummary.CrossRefTraktV2?.OrderByDescending(a => a.AniDBStartEpisodeNumber).ToList() ?? new List <VM_CrossRef_AniDB_TraktV2>();

                    bool foundStartingPoint            = false;
                    VM_CrossRef_AniDB_TraktV2 xrefBase = null;
                    foreach (VM_CrossRef_AniDB_TraktV2 xrefTrakt in traktCrossRef)
                    {
                        if (xrefTrakt.AniDBStartEpisodeType != (int)enEpisodeType.Special)
                        {
                            continue;
                        }
                        if (EpisodeNumber >= xrefTrakt.AniDBStartEpisodeNumber)
                        {
                            foundStartingPoint = true;
                            xrefBase           = xrefTrakt;
                            break;
                        }
                    }

                    if (traktSummary.CrossRefTraktV2 != null && traktSummary.CrossRefTraktV2.Count > 0)
                    {
                        // we have found the starting epiosde numbder from AniDB
                        // now let's check that the Trakt Season and Episode Number exist
                        if (foundStartingPoint)
                        {
                            Dictionary <int, int> dictTraktSeasons = null;
                            Dictionary <int, VM_Trakt_Episode> dictTraktEpisodes = null;
                            foreach (VM_TraktDetails det in traktSummary.traktDetails.Values)
                            {
                                if (det.TraktID.Equals(xrefBase.TraktID, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    dictTraktSeasons  = det.DictTraktSeasons;
                                    dictTraktEpisodes = det.DictTraktEpisodes;
                                    break;
                                }
                            }

                            if (dictTraktSeasons != null && dictTraktSeasons.ContainsKey(xrefBase.TraktSeasonNumber))
                            {
                                int episodeNumber = dictTraktSeasons[xrefBase.TraktSeasonNumber] + (EpisodeNumber + xrefBase.TraktStartEpisodeNumber - 2) - (xrefBase.AniDBStartEpisodeNumber - 1);
                                if (dictTraktEpisodes.ContainsKey(episodeNumber))
                                {
                                    VM_Trakt_Episode traktEp = dictTraktEpisodes[episodeNumber];
                                    TraktLinkExists  = true;
                                    TraktLinkMissing = false;

                                    TraktEpisodeURL = traktEp.URL;
                                }
                            }
                        }
                    }
                }
            }
            #endregion
        }