コード例 #1
0
		public bool Init(AnimeEpisode aniepisode)
		{
			try
			{
				if (string.IsNullOrEmpty(ServerSettings.Trakt_Username) || string.IsNullOrEmpty(ServerSettings.Trakt_Password))
					return false;
				
				username = ServerSettings.Trakt_Username;
				password = Utils.CalculateSHA1(ServerSettings.Trakt_Password, Encoding.Default);

				imdb_id = "";
				AnimeSeries ser = aniepisode.GetAnimeSeries();
				if (ser == null) return false;

				CrossRef_AniDB_TraktRepository repCrossRef = new CrossRef_AniDB_TraktRepository();
				CrossRef_AniDB_Trakt xref = repCrossRef.GetByAnimeID(ser.AniDB_ID);
				if (xref == null) return false;

				Trakt_ShowRepository repShows = new Trakt_ShowRepository();
				Trakt_Show show = repShows.GetByTraktID(xref.TraktID);
				if (show == null) return false;
				if (!show.TvDB_ID.HasValue) return false;

				tvdb_id = show.TvDB_ID.Value.ToString();
				title = show.Title;
				year = show.Year;

				int retEpNum = 0, retSeason = 0;
				GetTraktEpisodeNumber(aniepisode, show, xref.TraktSeasonNumber, ref retEpNum, ref retSeason);
				if (retEpNum < 0) return false;

				episode = retEpNum.ToString();
				season = retSeason.ToString();

				AniDB_Episode aniep = aniepisode.AniDB_Episode;
				if (aniep != null)
				{
					TimeSpan t = TimeSpan.FromSeconds(aniep.LengthSeconds + 14);
					int toMinutes = int.Parse(Math.Round(t.TotalMinutes).ToString());
					duration = toMinutes.ToString();
				}
				else
					duration = "25";

				progress = "100";

				plugin_version = "0.4";
				media_center_version = "1.2.0.1";
				media_center_date = "Dec 17 2010";

				
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
				return false;
			}

			return true;
		}
コード例 #2
0
 public void PopulateManually(VideoLocal vid, AnimeEpisode ep)
 {
     Hash           = vid.ED2KHash;
     FileName       = Path.GetFileName(vid.FullServerPath);
     FileSize       = vid.FileSize;
     CrossRefSource = (int)JMMServer.CrossRefSource.User;
     AnimeID        = ep.GetAnimeSeries().AniDB_ID;
     EpisodeID      = ep.AniDB_EpisodeID;
     Percentage     = 100;
     EpisodeOrder   = 1;
 }
コード例 #3
0
		public void PopulateManually(VideoLocal vid, AnimeEpisode ep)
		{
			Hash = vid.ED2KHash;
			FileName = Path.GetFileName(vid.FullServerPath);
			FileSize = vid.FileSize;
			CrossRefSource = (int)JMMServer.CrossRefSource.User;
			AnimeID = ep.GetAnimeSeries().AniDB_ID;
			EpisodeID = ep.AniDB_EpisodeID;
			Percentage = 100;
			EpisodeOrder = 1;
		}
コード例 #4
0
		private void GetTraktEpisodeNumber(AnimeEpisode aniepisode, Trakt_Show show, int season, ref int traktEpNum, ref int traktSeason)
		{
			try
			{
				traktEpNum = -1;
				traktSeason = -1;

				AnimeSeries ser = aniepisode.GetAnimeSeries();
				if (ser == null) return;

				//Dictionary<int, int> dictTraktSeasons = GetDictTraktSeasons(show);
				//Dictionary<int, Trakt_Episode> dictTraktEpisodes = GetDictTraktEpisodes(show);

				Dictionary<int, int> dictTraktSeasons = null;
				Dictionary<int, Trakt_Episode> dictTraktEpisodes = null;
				GetDictTraktEpisodesAndSeasons(show, ref dictTraktEpisodes, ref dictTraktSeasons);

				int epNum = aniepisode.AniDB_Episode.EpisodeNumber;
				
				//episode
				if (aniepisode.EpisodeTypeEnum == AniDBAPI.enEpisodeType.Episode)
				{
					if (dictTraktEpisodes != null && dictTraktSeasons != null)
					{
						if (dictTraktSeasons.ContainsKey(season))
						{
							int absEpisodeNumber = dictTraktSeasons[season] + epNum - 1;
							if (dictTraktEpisodes.ContainsKey(absEpisodeNumber))
							{
								Trakt_Episode tvep = dictTraktEpisodes[absEpisodeNumber];
								traktEpNum = tvep.EpisodeNumber;
								traktSeason = tvep.Season;
							}
						}
					}
				}

				if (aniepisode.EpisodeTypeEnum == AniDBAPI.enEpisodeType.Special)
				{
					traktSeason = 0;
					traktEpNum = epNum;
				}

				return;
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
				return;
			}
		}
コード例 #5
0
ファイル: VideoLocal.cs プロジェクト: RickDB/jmmserver
        public void ToggleWatchedStatus(bool watched, bool updateOnline, DateTime?watchedDate, bool updateStats,
                                        bool updateStatsCache, int userID,
                                        bool syncTrakt, bool updateWatchedDate)
        {
            JMMUser user = RepoFactory.JMMUser.GetByID(userID);

            if (user == null)
            {
                return;
            }

            List <JMMUser> aniDBUsers = RepoFactory.JMMUser.GetAniDBUsers();

            // update the video file to watched
            int mywatched = watched ? 1 : 0;

            if (user.IsAniDBUser == 0)
            {
                SaveWatchedStatus(watched, userID, watchedDate, updateWatchedDate);
            }
            else
            {
                // if the user is AniDB user we also want to update any other AniDB
                // users to keep them in sync
                foreach (JMMUser juser in aniDBUsers)
                {
                    if (juser.IsAniDBUser == 1)
                    {
                        SaveWatchedStatus(watched, juser.JMMUserID, watchedDate, updateWatchedDate);
                    }
                }
            }


            // now lets find all the associated AniDB_File record if there is one
            if (user.IsAniDBUser == 1)
            {
                AniDB_File aniFile = RepoFactory.AniDB_File.GetByHash(this.Hash);
                if (aniFile != null)
                {
                    aniFile.IsWatched = mywatched;

                    if (watched)
                    {
                        if (watchedDate.HasValue)
                        {
                            aniFile.WatchedDate = watchedDate;
                        }
                        else
                        {
                            aniFile.WatchedDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        aniFile.WatchedDate = null;
                    }


                    RepoFactory.AniDB_File.Save(aniFile, false);
                }

                if (updateOnline)
                {
                    if ((watched && ServerSettings.AniDB_MyList_SetWatched) ||
                        (!watched && ServerSettings.AniDB_MyList_SetUnwatched))
                    {
                        CommandRequest_UpdateMyListFileStatus cmd = new CommandRequest_UpdateMyListFileStatus(
                            this.Hash, watched, false,
                            watchedDate.HasValue ? Utils.GetAniDBDateAsSeconds(watchedDate) : 0);
                        cmd.Save();
                    }
                }
            }

            // now find all the episode records associated with this video file
            // but we also need to check if theer are any other files attached to this episode with a watched
            // status,


            AnimeSeries ser = null;
            // get all files associated with this episode
            List <CrossRef_File_Episode>  xrefs          = RepoFactory.CrossRef_File_Episode.GetByHash(this.Hash);
            Dictionary <int, AnimeSeries> toUpdateSeries = new Dictionary <int, AnimeSeries>();

            if (watched)
            {
                // find the total watched percentage
                // eg one file can have a % = 100
                // or if 2 files make up one episodes they will each have a % = 50

                foreach (CrossRef_File_Episode xref in xrefs)
                {
                    // get the episodes for this file, may be more than one (One Piece x Toriko)
                    AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(xref.EpisodeID);
                    // get all the files for this episode
                    int epPercentWatched = 0;
                    foreach (CrossRef_File_Episode filexref in ep.FileCrossRefs)
                    {
                        VideoLocal_User vidUser = filexref.GetVideoLocalUserRecord(userID);
                        if (vidUser != null && vidUser.WatchedDate.HasValue)
                        {
                            // if not null means it is watched
                            epPercentWatched += filexref.Percentage;
                        }

                        if (epPercentWatched > 95)
                        {
                            break;
                        }
                    }

                    if (epPercentWatched > 95)
                    {
                        ser = ep.GetAnimeSeries();
                        if (!toUpdateSeries.ContainsKey(ser.AnimeSeriesID))
                        {
                            toUpdateSeries.Add(ser.AnimeSeriesID, ser);
                        }
                        if (user.IsAniDBUser == 0)
                        {
                            ep.SaveWatchedStatus(true, userID, watchedDate, updateWatchedDate);
                        }
                        else
                        {
                            // if the user is AniDB user we also want to update any other AniDB
                            // users to keep them in sync
                            foreach (JMMUser juser in aniDBUsers)
                            {
                                if (juser.IsAniDBUser == 1)
                                {
                                    ep.SaveWatchedStatus(true, juser.JMMUserID, watchedDate, updateWatchedDate);
                                }
                            }
                        }

                        if (syncTrakt && ServerSettings.Trakt_IsEnabled &&
                            !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
                        {
                            CommandRequest_TraktHistoryEpisode cmdSyncTrakt =
                                new CommandRequest_TraktHistoryEpisode(ep.AnimeEpisodeID, TraktSyncAction.Add);
                            cmdSyncTrakt.Save();
                        }

                        if (!string.IsNullOrEmpty(ServerSettings.MAL_Username) &&
                            !string.IsNullOrEmpty(ServerSettings.MAL_Password))
                        {
                            CommandRequest_MALUpdatedWatchedStatus cmdMAL =
                                new CommandRequest_MALUpdatedWatchedStatus(ser.AniDB_ID);
                            cmdMAL.Save();
                        }
                    }
                }
            }
            else
            {
                // if setting a file to unwatched only set the episode unwatched, if ALL the files are unwatched
                foreach (CrossRef_File_Episode xrefEp in xrefs)
                {
                    // get the episodes for this file, may be more than one (One Piece x Toriko)
                    AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(xrefEp.EpisodeID);
                    ser = ep.GetAnimeSeries();
                    if (!toUpdateSeries.ContainsKey(ser.AnimeSeriesID))
                    {
                        toUpdateSeries.Add(ser.AnimeSeriesID, ser);
                    }
                    // get all the files for this episode
                    int epPercentWatched = 0;
                    foreach (CrossRef_File_Episode filexref in ep.FileCrossRefs)
                    {
                        VideoLocal_User vidUser = filexref.GetVideoLocalUserRecord(userID);
                        if (vidUser != null && vidUser.WatchedDate.HasValue)
                        {
                            epPercentWatched += filexref.Percentage;
                        }

                        if (epPercentWatched > 95)
                        {
                            break;
                        }
                    }

                    if (epPercentWatched < 95)
                    {
                        if (user.IsAniDBUser == 0)
                        {
                            ep.SaveWatchedStatus(false, userID, watchedDate, true);
                        }
                        else
                        {
                            // if the user is AniDB user we also want to update any other AniDB
                            // users to keep them in sync
                            foreach (JMMUser juser in aniDBUsers)
                            {
                                if (juser.IsAniDBUser == 1)
                                {
                                    ep.SaveWatchedStatus(false, juser.JMMUserID, watchedDate, true);
                                }
                            }
                        }

                        if (syncTrakt && ServerSettings.Trakt_IsEnabled &&
                            !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
                        {
                            CommandRequest_TraktHistoryEpisode cmdSyncTrakt =
                                new CommandRequest_TraktHistoryEpisode(ep.AnimeEpisodeID, TraktSyncAction.Remove);
                            cmdSyncTrakt.Save();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(ServerSettings.MAL_Username) &&
                    !string.IsNullOrEmpty(ServerSettings.MAL_Password))
                {
                    CommandRequest_MALUpdatedWatchedStatus cmdMAL =
                        new CommandRequest_MALUpdatedWatchedStatus(ser.AniDB_ID);
                    cmdMAL.Save();
                }
            }


            // update stats for groups and series
            if (toUpdateSeries.Count > 0 && updateStats)
            {
                foreach (AnimeSeries s in toUpdateSeries.Values)
                {
                    // update all the groups above this series in the heirarchy
                    s.UpdateStats(true, true, true);
                }
                //ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
            }

            //if (ser != null && updateStatsCache)
            //StatsCache.Instance.UpdateUsingSeries(ser.AnimeSeriesID);
        }
コード例 #6
0
ファイル: VideoLocal.cs プロジェクト: ewelike23/jmm
        public void ToggleWatchedStatus(bool watched, bool updateOnline, DateTime?watchedDate, bool updateStats, bool updateStatsCache, int userID,
                                        bool scrobbleTrakt, bool updateWatchedDate)
        {
            VideoLocalRepository            repVids     = new VideoLocalRepository();
            AnimeEpisodeRepository          repEpisodes = new AnimeEpisodeRepository();
            AniDB_FileRepository            repAniFile  = new AniDB_FileRepository();
            CrossRef_File_EpisodeRepository repCross    = new CrossRef_File_EpisodeRepository();
            VideoLocal_UserRepository       repVidUsers = new VideoLocal_UserRepository();
            JMMUserRepository           repUsers        = new JMMUserRepository();
            AnimeEpisode_UserRepository repEpisodeUsers = new AnimeEpisode_UserRepository();

            JMMUser user = repUsers.GetByID(userID);

            if (user == null)
            {
                return;
            }

            List <JMMUser> aniDBUsers = repUsers.GetAniDBUsers();

            // update the video file to watched
            int mywatched = watched ? 1 : 0;

            if (user.IsAniDBUser == 0)
            {
                SaveWatchedStatus(watched, userID, watchedDate, updateWatchedDate);
            }
            else
            {
                // if the user is AniDB user we also want to update any other AniDB
                // users to keep them in sync
                foreach (JMMUser juser in aniDBUsers)
                {
                    if (juser.IsAniDBUser == 1)
                    {
                        SaveWatchedStatus(watched, juser.JMMUserID, watchedDate, updateWatchedDate);
                    }
                }
            }


            // now lets find all the associated AniDB_File record if there is one
            if (user.IsAniDBUser == 1)
            {
                AniDB_File aniFile = repAniFile.GetByHash(this.Hash);
                if (aniFile != null)
                {
                    aniFile.IsWatched = mywatched;

                    if (watched)
                    {
                        if (watchedDate.HasValue)
                        {
                            aniFile.WatchedDate = watchedDate;
                        }
                        else
                        {
                            aniFile.WatchedDate = DateTime.Now;
                        }
                    }
                    else
                    {
                        aniFile.WatchedDate = null;
                    }


                    repAniFile.Save(aniFile, false);
                }

                if (updateOnline)
                {
                    if ((watched && ServerSettings.AniDB_MyList_SetWatched) || (!watched && ServerSettings.AniDB_MyList_SetUnwatched))
                    {
                        CommandRequest_UpdateMyListFileStatus cmd = new CommandRequest_UpdateMyListFileStatus(this.Hash, watched, false,
                                                                                                              watchedDate.HasValue ? Utils.GetAniDBDateAsSeconds(watchedDate) : 0);
                        cmd.Save();
                    }
                }
            }

            // now find all the episode records associated with this video file
            // but we also need to check if theer are any other files attached to this episode with a watched
            // status,


            AnimeSeries ser = null;
            // get all files associated with this episode
            List <CrossRef_File_Episode> xrefs = repCross.GetByHash(this.Hash);

            if (watched)
            {
                // find the total watched percentage
                // eg one file can have a % = 100
                // or if 2 files make up one episodes they will each have a % = 50

                foreach (CrossRef_File_Episode xref in xrefs)
                {
                    // get the episode for this file
                    AnimeEpisode ep = repEpisodes.GetByAniDBEpisodeID(xref.EpisodeID);
                    if (ep == null)
                    {
                        continue;
                    }

                    // get all the files for this episode
                    int epPercentWatched = 0;
                    foreach (CrossRef_File_Episode filexref in ep.FileCrossRefs)
                    {
                        VideoLocal_User vidUser = filexref.GetVideoLocalUserRecord(userID);
                        if (vidUser != null)
                        {
                            // if not null means it is watched
                            epPercentWatched += filexref.Percentage;
                        }

                        if (epPercentWatched > 95)
                        {
                            break;
                        }
                    }

                    if (epPercentWatched > 95)
                    {
                        ser = ep.GetAnimeSeries();

                        if (user.IsAniDBUser == 0)
                        {
                            ep.SaveWatchedStatus(true, userID, watchedDate, updateWatchedDate);
                        }
                        else
                        {
                            // if the user is AniDB user we also want to update any other AniDB
                            // users to keep them in sync
                            foreach (JMMUser juser in aniDBUsers)
                            {
                                if (juser.IsAniDBUser == 1)
                                {
                                    ep.SaveWatchedStatus(true, juser.JMMUserID, watchedDate, updateWatchedDate);
                                }
                            }
                        }

                        if (scrobbleTrakt && !string.IsNullOrEmpty(ServerSettings.Trakt_Username) && !string.IsNullOrEmpty(ServerSettings.Trakt_Password))
                        {
                            CommandRequest_TraktShowScrobble cmdScrobble = new CommandRequest_TraktShowScrobble(ep.AnimeEpisodeID);
                            cmdScrobble.Save();
                        }

                        if (!string.IsNullOrEmpty(ServerSettings.MAL_Username) && !string.IsNullOrEmpty(ServerSettings.MAL_Password))
                        {
                            CommandRequest_MALUpdatedWatchedStatus cmdMAL = new CommandRequest_MALUpdatedWatchedStatus(ser.AniDB_ID);
                            cmdMAL.Save();
                        }
                    }
                }
            }
            else
            {
                // if setting a file to unwatched only set the episode unwatched, if ALL the files are unwatched
                foreach (CrossRef_File_Episode xrefEp in xrefs)
                {
                    AnimeEpisode ep = repEpisodes.GetByAniDBEpisodeID(xrefEp.EpisodeID);
                    if (ep == null)
                    {
                        continue;
                    }
                    ser = ep.GetAnimeSeries();

                    // get all the files for this episode
                    int epPercentWatched = 0;
                    foreach (CrossRef_File_Episode filexref in ep.FileCrossRefs)
                    {
                        VideoLocal_User vidUser = filexref.GetVideoLocalUserRecord(userID);
                        if (vidUser != null)
                        {
                            epPercentWatched += filexref.Percentage;
                        }

                        if (epPercentWatched > 95)
                        {
                            break;
                        }
                    }

                    if (epPercentWatched < 95)
                    {
                        if (user.IsAniDBUser == 0)
                        {
                            ep.SaveWatchedStatus(false, userID, watchedDate, true);
                        }
                        else
                        {
                            // if the user is AniDB user we also want to update any other AniDB
                            // users to keep them in sync
                            foreach (JMMUser juser in aniDBUsers)
                            {
                                if (juser.IsAniDBUser == 1)
                                {
                                    ep.SaveWatchedStatus(false, juser.JMMUserID, watchedDate, true);
                                }
                            }
                        }

                        CommandRequest_TraktShowEpisodeUnseen cmdUnseen = new CommandRequest_TraktShowEpisodeUnseen(ep.AnimeEpisodeID);
                        cmdUnseen.Save();
                    }
                }

                if (!string.IsNullOrEmpty(ServerSettings.MAL_Username) && !string.IsNullOrEmpty(ServerSettings.MAL_Password))
                {
                    CommandRequest_MALUpdatedWatchedStatus cmdMAL = new CommandRequest_MALUpdatedWatchedStatus(ser.AniDB_ID);
                    cmdMAL.Save();
                }
            }


            // update stats for groups and series
            if (ser != null && updateStats)
            {
                // update all the groups above this series in the heirarchy
                ser.UpdateStats(true, true, true);
                //ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
            }

            if (ser != null && updateStatsCache)
            {
                StatsCache.Instance.UpdateUsingSeries(ser.AnimeSeriesID);
            }
        }
コード例 #7
0
ファイル: TraktTVHelper.cs プロジェクト: dizzydezz/jmm
		public static void MarkEpisodeUnwatched(AnimeEpisode ep)
		{
			try
			{
				if (string.IsNullOrEmpty(ServerSettings.Trakt_Username) || string.IsNullOrEmpty(ServerSettings.Trakt_Password))
					return;

				CrossRef_AniDB_Trakt xref = ep.GetAnimeSeries().CrossRefTrakt;
				if (xref == null) return;

				Trakt_ShowRepository repShows = new Trakt_ShowRepository();
				Trakt_Show show = repShows.GetByTraktID(xref.TraktID);
				if (show == null) return;
				if (!show.TvDB_ID.HasValue) return;

				Dictionary<int, int> dictTraktSeasons = null;
				Dictionary<int, Trakt_Episode> dictTraktEpisodes = null;
				Dictionary<int, Trakt_Episode> dictTraktSpecials = null;
				GetDictTraktEpisodesAndSeasons(show, ref dictTraktEpisodes, ref dictTraktSpecials, ref dictTraktSeasons);

				TraktTVPost_ShowEpisodeUnseen postUnseen = new TraktTVPost_ShowEpisodeUnseen();
				postUnseen.episodes = new List<TraktTVSeasonEpisode>();
				postUnseen.SetCredentials();
				postUnseen.imdb_id = "";
				postUnseen.title = show.Title;
				postUnseen.year = show.Year;
				postUnseen.tvdb_id = show.TvDB_ID.Value.ToString();

				int retEpNum = -1;
				int retSeason = -1;

				GetTraktEpisodeNumber(ep, ep.GetAnimeSeries(), show, xref.TraktSeasonNumber, ref retEpNum, ref retSeason, dictTraktEpisodes, dictTraktSpecials, dictTraktSeasons);
				if (retEpNum < 0) return;

				TraktTVSeasonEpisode traktEp = new TraktTVSeasonEpisode();
				traktEp.episode = retEpNum.ToString();
				traktEp.season = retSeason.ToString();
				postUnseen.episodes.Add(traktEp);

				logger.Trace("Marking episode as unwatched on Trakt: {0} - S{1} - EP{2}", show.Title, retSeason, retEpNum);

				string urlUnseen = string.Format(Constants.TraktTvURLs.URLPostShowEpisodeUnseen, Constants.TraktTvURLs.APIKey);
				string json = JSONHelper.Serialize<TraktTVPost_ShowEpisodeUnseen>(postUnseen);

				SendData(urlUnseen, json);

			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in TraktTVHelper.MarkEpisodeWatched: " + ex.ToString(), ex);
			}

		}
コード例 #8
0
ファイル: TraktTVHelper.cs プロジェクト: dizzydezz/jmm
		/*public static void MarkEpisodeWatched(AnimeEpisode ep)
		{
			TraktTVPost_ShowScrobble tt = new TraktTVPost_ShowScrobble();
			if (!tt.Init(ep)) return;

			try
			{
				string url = string.Format(Constants.TraktTvURLs.URLPostShowScrobble, Constants.TraktTvURLs.APIKey);
				logger.Trace("GetShowInfo: {0}", url);

				logger.Trace("Marking episode as unwatched on Trakt: {0} - S{1} - EP{2}", show.Title, retSeason, retEpNum);

				string json = JSONHelper.Serialize<TraktTVPost_ShowScrobble>(tt);

				SendData(url, json);

			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in TraktTVHelper.MarkEpisodeWatched: " + ex.ToString(), ex);
			}

		}*/

		public static void MarkEpisodeWatched(AnimeEpisode ep)
		{
			try
			{
				if (string.IsNullOrEmpty(ServerSettings.Trakt_Username) || string.IsNullOrEmpty(ServerSettings.Trakt_Password))
					return;

				CrossRef_AniDB_Trakt xref = ep.GetAnimeSeries().CrossRefTrakt;
				if (xref == null) return;

				Trakt_ShowRepository repShows = new Trakt_ShowRepository();
				Trakt_Show show = repShows.GetByTraktID(xref.TraktID);
				if (show == null) return;
				if (!show.TvDB_ID.HasValue) return;

				Dictionary<int, int> dictTraktSeasons = null;
				Dictionary<int, Trakt_Episode> dictTraktEpisodes = null;
				Dictionary<int, Trakt_Episode> dictTraktSpecials = null;
				GetDictTraktEpisodesAndSeasons(show, ref dictTraktEpisodes, ref dictTraktSpecials, ref dictTraktSeasons);

				int retEpNum = -1;
				int retSeason = -1;

				GetTraktEpisodeNumber(ep, ep.GetAnimeSeries(), show, xref.TraktSeasonNumber, ref retEpNum, ref retSeason, dictTraktEpisodes, dictTraktSpecials, dictTraktSeasons);
				if (retEpNum < 0) return;

				TraktTVPost_ShowScrobble postScrobble = new TraktTVPost_ShowScrobble();
				postScrobble.SetCredentials();
				postScrobble.imdb_id = "";
				postScrobble.title = show.Title;
				postScrobble.year = show.Year;
				postScrobble.tvdb_id = show.TvDB_ID.Value.ToString();
				postScrobble.episode = retEpNum.ToString();
				postScrobble.season = retSeason.ToString();

				AniDB_Episode aniep = ep.AniDB_Episode;
				if (aniep != null)
				{
					TimeSpan t = TimeSpan.FromSeconds(aniep.LengthSeconds + 14);
					int toMinutes = int.Parse(Math.Round(t.TotalMinutes).ToString());
					postScrobble.duration = toMinutes.ToString();
				}
				else
					postScrobble.duration = "25";

				postScrobble.progress = "100";

				postScrobble.plugin_version = "0.4";
				postScrobble.media_center_version = "1.2.0.1";
				postScrobble.media_center_date = "Dec 17 2010";
			
				logger.Trace("Marking episode as watched (scrobble) on Trakt: {0} - S{1} - EP{2}", show.Title, retSeason, retEpNum);

				string url = string.Format(Constants.TraktTvURLs.URLPostShowScrobble, Constants.TraktTvURLs.APIKey);
				string json = JSONHelper.Serialize<TraktTVPost_ShowScrobble>(postScrobble);

				SendData(url, json);

			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in TraktTVHelper.MarkEpisodeWatched: " + ex.ToString(), ex);
			}

		}