Beispiel #1
0
 /// <summary>
 /// Performs a full sync on a single episodes
 /// </summary>
 /// <param name="episode">A BulkEpisode object holding episode information to sync</param>
 public FitEpisode BulkAction(FitEpisode episode)
 {
     return BulkAction(new[] { episode })[0];
 }
Beispiel #2
0
        /// <summary>
        /// Performs a full sync on a sequence of episodes
        /// </summary>
        /// <param name="episodes">A sequence of episodes</param>
        public List<FitEpisode> BulkAction(IEnumerable<FitEpisode> episodes)
        {
            var episodesArray = episodes.ToArray();
            episodesArray.All(e => !e.Rating.HasValue || checkValidRatingValueProvided(e.Rating.Value));

            List<FitEpisode> rtn = new List<FitEpisode>();
            foreach (XmlRpcStruct currRecord in Proxy.BulkAction(episodesArray)) {
                FitEpisode currEp = new FitEpisode();
                currEp.FollwitId = (string) currRecord["EpisodeId"];
                currEp.SourceName = (string)currRecord["SourceName"];
                currEp.SourceId = (string)currRecord["SourceId"];
                currEp.Rating = int.Parse((string)currRecord["Rating"]);
                currEp.Watched = currRecord["Watched"].Equals("1");

                rtn.Add(currEp);
            }

            return rtn;
        }
        public static FitEpisode GetFitEpisode(DBEpisode mptvEpisode)
        {
            if (mptvEpisode == null)
                return null;

            FitEpisode fitEp = new FitEpisode();
            fitEp.SourceName = "tvdb";
            fitEp.SourceId = mptvEpisode.onlineEpisode[DBOnlineEpisode.cID];
            fitEp.InCollection = true;

            if (!String.IsNullOrEmpty(mptvEpisode[DBOnlineEpisode.cMyRating])) {
                int value;
                int.TryParse(mptvEpisode[DBOnlineEpisode.cMyRating], out value);
                fitEp.Rating = (int)Math.Round(value / 2.0, MidpointRounding.AwayFromZero);
            }

            fitEp.Watched = mptvEpisode[DBOnlineEpisode.cWatched] == 1;

            return fitEp;
        }