/// <summary>
        /// Creates Sync Data based on a TraktLibraryShows object
        /// </summary>
        /// <param name="show">The show to base the object on</param>
        /// <returns>The Trakt Sync data to send</returns>
        public static TraktEpisodeSync CreateEpisodeSyncData(TraktLibraryShow show)
        {
            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                SeriesID = show.SeriesId,
                Title = show.Title,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            var episodes = new List<TraktEpisodeSync.Episode>();

            foreach(var season in show.Seasons)
            {
                foreach (var episode in season.Episodes)
                {
                    episodes.Add(new TraktEpisodeSync.Episode
                                     {
                                         EpisodeIndex = episode.ToString(),
                                         SeasonIndex = season.Season.ToString()
                                     });
                }
            }

            syncData.EpisodeList = episodes;

            return syncData;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes episodes on trakt that no longer exist in users database
        /// </summary>
        /// <param name="traktShows">trakt episode collection</param>
        /// <param name="episodes">list of local episodes</param>
        /// <param name="seriesID">tvdb series id of series</param>
        /// <returns>true if episode exists</returns>
        private TraktEpisodeSync GetEpisodesForTraktRemoval(TraktLibraryShow traktShow, List<DBEpisode> episodes)
        {
            List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>();

            foreach (var season in traktShow.Seasons)
            {
                foreach (var episode in season.Episodes)
                {
                    var query = episodes.Where(e => e[DBOnlineEpisode.cSeriesID] == traktShow.SeriesId &&
                                                    e[DBOnlineEpisode.cSeasonIndex] == season.Season &&
                                                    e[DBOnlineEpisode.cEpisodeIndex] == episode).ToList();

                    if (query.Count == 0)
                    {
                        // we dont have the episode
                        TraktLogger.Info("{0} - {1}x{2} does not exist in local database, marked for removal from trakt", traktShow.ToString(), season.Season.ToString(), episode.ToString());

                        TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode
                        {
                            EpisodeIndex = episode.ToString(),
                            SeasonIndex = season.Season.ToString()
                        };
                        episodeList.Add(ep);
                    }
                }
            }

            if (episodeList.Count > 0)
            {
                TraktEpisodeSync syncData = new TraktEpisodeSync
                {
                    UserName = TraktSettings.Username,
                    Password = TraktSettings.Password,
                    SeriesID = traktShow.SeriesId,
                    EpisodeList = episodeList
                };
                return syncData;
            }
            return null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates Sync Data based on Series object and a List of Episode objects
        /// </summary>
        /// <param name="series">The series to base the object on</param>
        /// <param name="epsiodes">The list of episodes to base the object on</param>
        /// <returns>The Trakt Sync data to send</returns>
        private TraktEpisodeSync CreateSyncData(DBSeries series, List<DBEpisode> episodes)
        {
            if (series == null || series[DBOnlineSeries.cTraktIgnore]) return null;

            // set series properties for episodes
            TraktEpisodeSync traktSync = new TraktEpisodeSync
            {
                Password = TraktSettings.Password,
                UserName = TraktSettings.Username,
                SeriesID = series[DBSeries.cID],
                IMDBID = series[DBOnlineSeries.cIMDBID],
                Year = series.Year,
                Title = series[DBOnlineSeries.cOriginalName]
            };

            // get list of episodes for series
            List<TraktEpisodeSync.Episode> epList = new List<TraktEpisodeSync.Episode>();

            foreach (DBEpisode ep in episodes.Where(e => e[DBEpisode.cSeriesID] == series[DBSeries.cID]))
            {
                TraktEpisodeSync.Episode episode = new TraktEpisodeSync.Episode();
                episode.SeasonIndex = ep[DBOnlineEpisode.cSeasonIndex];
                episode.EpisodeIndex = ep[DBOnlineEpisode.cEpisodeIndex];
                epList.Add(episode);
            }

            traktSync.EpisodeList = epList;
            return traktSync;
        }
        public static TraktEpisodeSync CreateEpisodeSyncData(string title, string year, string tvdbid, string seasonidx, string episodeidx)
        {
            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                SeriesID = tvdbid,
                Title = title,
                EpisodeList = new List<TraktEpisodeSync.Episode>{ new TraktEpisodeSync.Episode { EpisodeIndex = episodeidx, SeasonIndex = seasonidx } },
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            return syncData;
        }
Exemplo n.º 5
0
        private TraktEpisodeSync CreateEpisodeSyncData(TraktCalendar.TraktEpisodes episode)
        {
            List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>();
            episodeList.Add(new TraktEpisodeSync.Episode { EpisodeIndex = episode.Episode.Number.ToString(), SeasonIndex = episode.Episode.Season.ToString() });

            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                EpisodeList = episodeList,
                IMDBID = episode.Show.Imdb,
                SeriesID = episode.Show.Tvdb,
                Title = episode.Show.Title,
                Year = episode.Show.Year.ToString(),
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            return syncData;
        }
        private TraktEpisodeSync CreateSyncData(KeyValuePair<TraktShow, TraktWatchListEpisode.Episode> item)
        {
            var series = item.Key;
            var episode = item.Value;

            List<TraktEpisodeSync.Episode> episodes = new List<TraktEpisodeSync.Episode>();

            TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode
            {
                EpisodeIndex = episode.Number.ToString(),
                SeasonIndex = episode.Season.ToString()
            };
            episodes.Add(ep);

            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                SeriesID = series.Tvdb,
                Title = series.Title,
                Year = series.Year.ToString(),
                EpisodeList = episodes
            };

            return syncData;
        }
        private TraktEpisodeSync CreateEpisodeSyncData(TraktEpisode episode)
        {
            List<TraktEpisodeSync.Episode> episodes = new List<TraktEpisodeSync.Episode>();

            TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode
            {
                EpisodeIndex = episode.Number.ToString(),
                SeasonIndex = episode.Season.ToString()
            };
            episodes.Add(ep);

            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                SeriesID = Show.Tvdb,
                Title = Show.Title,
                Year = Show.Year.ToString(),
                EpisodeList = episodes
            };

            return syncData;
        }
        private TraktEpisodeSync CreateEpisodeSyncData(TraktUserListItem item)
        {
            if (item == null) return null;

            TraktEpisodeSync.Episode syncEpisode = new TraktEpisodeSync.Episode
            {
                EpisodeIndex = item.EpisodeNumber.ToString(),
                SeasonIndex = item.SeasonNumber.ToString()
            };

            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                SeriesID = item.Show.Tvdb,
                Title = item.Show.Title,
                Year = item.Year,
                EpisodeList = new List<TraktEpisodeSync.Episode> { syncEpisode }
            };

            return syncData;
        }
Exemplo n.º 9
0
        protected void AddItemToWatchList()
        {
            if (!CheckTraktLogin()) return;

            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktResponse response = null;

                if (listLevel != Listlevel.Episode)
                {
                    response = TraktAPI.SyncShowWatchList(BasicHandler.CreateShowSyncData(m_SelectedSeries[DBOnlineSeries.cPrettyName], m_SelectedSeries.Year, m_SelectedSeries[DBSeries.cID]), TraktSyncModes.watchlist);
                    if (response != null && response.Status == "success")
                        TraktPlugin.GUI.GUIWatchListShows.ClearCache(TraktPlugin.TraktSettings.Username);
                }
                else
                {
                    List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>();
                    episodeList.Add(new TraktEpisodeSync.Episode { EpisodeIndex = m_SelectedEpisode[DBOnlineEpisode.cEpisodeIndex], SeasonIndex = m_SelectedEpisode[DBOnlineEpisode.cSeasonIndex] });

                    TraktEpisodeSync syncData = new TraktEpisodeSync
                    {
                        UserName = TraktPlugin.TraktSettings.Username,
                        Password = TraktPlugin.TraktSettings.Password,
                        Title = m_SelectedSeries[DBOnlineSeries.cPrettyName],
                        Year = m_SelectedSeries.Year,
                        SeriesID = m_SelectedEpisode[DBOnlineEpisode.cSeriesID],
                        EpisodeList = episodeList
                    };
                    response = TraktAPI.SyncEpisodeWatchList(syncData, TraktSyncModes.watchlist);
                }
            })
            {
                IsBackground = true,
                Name = "Adding Item to Watch List"
            };

            syncThread.Start();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Removes episodes on trakt that no longer exist in users database
        /// </summary>
        /// <param name="traktShows">trakt episode collection</param>
        /// <param name="episodes">list of local episodes</param>
        /// <param name="seriesID">tvdb series id of series</param>
        /// <returns>true if episode exists</returns>
        private TraktEpisodeSync GetEpisodesForTraktRemoval(TraktLibraryShow traktShow, List<FileLocal> episodes)
        {
            List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>();

            foreach (var season in traktShow.Seasons)
            {
                foreach (var episode in season.Episodes)
                {

                    var query = episodes.Where(e => e.AniDB_File != null && e.AniDB_File.AnimeSeries.TvDB_ID.ToString() == traktShow.SeriesId &&
                                                    e.AniDB_File.AnimeSeries.TvDB_Episodes.Where(t => !string.IsNullOrEmpty(t.Filename) && t.SeasonNumber == season.Season && t.EpisodeNumber == episode).Count() == 1).ToList();

                    if (query.Count == 0)
                    {
                        // we dont have the episode anymore
                        TraktLogger.Info("{0} - {1}x{2} does not exist in local database, marked for removal from trakt", traktShow.ToString(), season.Season.ToString(), episode.ToString());

                        TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode
                        {
                            EpisodeIndex = episode.ToString(),
                            SeasonIndex = season.Season.ToString()
                        };
                        episodeList.Add(ep);
                    }
                }
            }

            if (episodeList.Count > 0)
            {
                TraktEpisodeSync syncData = new TraktEpisodeSync
                {
                    UserName = TraktSettings.Username,
                    Password = TraktSettings.Password,
                    SeriesID = traktShow.SeriesId,
                    EpisodeList = episodeList
                };
                return syncData;
            }
            return null;
        }
Exemplo n.º 11
0
        private TraktEpisodeSync CreateSyncData(AnimeSeries series, List<AnimeEpisode> episodes)
        {
            if (series == null || series.TvDB_ID == null) return null;

            // set series properties for episodes
            TraktEpisodeSync traktSync = new TraktEpisodeSync
            {
                Password = TraktSettings.Password,
                UserName = TraktSettings.Username,
                SeriesID = series.TvDB_ID.ToString(),
                Year = GetStartYear(series),
                Title = series.SeriesName
            };

            // get list of episodes for series
            List<TraktEpisodeSync.Episode> epList = new List<TraktEpisodeSync.Episode>();

            foreach (AnimeEpisode episode in episodes.Where(e => e.Series.TvDB_ID == series.TvDB_ID))
            {
                TraktEpisodeSync.Episode ep = new TraktEpisodeSync.Episode();

                string seriesid = series.TvDB_ID.ToString();
                int seasonidx = 0;
                int episodeidx = 0;

                if (GetTVDBEpisodeInfo(episode, out seriesid, out seasonidx, out episodeidx))
                {
                    ep.SeasonIndex = seasonidx.ToString();
                    ep.EpisodeIndex = episodeidx.ToString();
                    epList.Add(ep);
                }
                else
                {
                    TraktLogger.Info("Unable to find match for episode: '{0} | airDate: {1}'", episode.ToString(), episode.AniDB_Episode.AirDateAsDate.ToString("yyyy-MM-dd"));
                }
            }

            if (epList.Count == 0)
            {
                TraktLogger.Warning("Unable to find any matching TVDb episodes for series '{0}', confirm Absolute Order and/or Episode Names and/or AirDates for episodes are correct on http://theTVDb.com and your database.", series.SeriesName);
                return null;
            }

            traktSync.EpisodeList = epList;
            return traktSync;
        }