Ejemplo n.º 1
0
        private bool CallShowAPI(WebTVEpisodeBasic episode, TraktWatchStatus state, int?progress)
        {
            WebTVShowDetailed   show   = MediaService.GetTVShowDetailedById(episode.PID, episode.ShowId);
            WebTVSeasonDetailed season = MediaService.GetTVSeasonDetailedById(episode.PID, episode.SeasonId);

            var data = new TraktEpisodeScrobbleData()
            {
                MediaCenter          = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion   = TraktConfig.MediaCenterVersion,
                PluginVersion        = TraktConfig.PluginVersion,
                Password             = Configuration["passwordHash"],
                UserName             = Configuration["username"],

                Duration = show.Runtime.ToString(),
                Episode  = episode.EpisodeNumber.ToString(),
                Season   = season.SeasonNumber.ToString(),
                Title    = show.Title,
                Year     = show.Year.ToString(),
            };

            if (progress != null)
            {
                data.Progress = progress.Value.ToString();
            }

            if (show.ExternalId.Count(x => x.Site == "IMDB") > 0)
            {
                data.IMDBID = show.ExternalId.First(x => x.Site == "IMDB").Id;
            }
            if (show.ExternalId.Count(x => x.Site == "TVDB") > 0)
            {
                data.TVDBID = show.ExternalId.First(x => x.Site == "TVDB").Id;
            }
            if (data.IMDBID == null && data.TVDBID == null)
            {
                Log.Info("Trakt: IMDB and TVDB unknown of episode {0}, not sending", episode.Title);
                return(false);
            }

            try
            {
                Log.Debug("Trakt: calling service for show {0} (episode {1}) with progress {2} and state {3}", data.Title, episode.Title, data.Progress, state.ToString());
                TraktResponse response = TraktAPI.ScrobbleEpisode(data, state);
                if (response.Status != "success")
                {
                    Log.Warn("Trakt: failed to update watch status of episode '{0}' ({1}): {2}", episode.Title, episode.Id, response.Error);
                    return(false);
                }
                Log.Trace("Trakt: finished service call");
                return(true);
            }
            catch (Exception ex)
            {
                Log.Warn("Trakt: failed to call service", ex);
                return(false);
            }
        }
Ejemplo n.º 2
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     Log.Debug("WSD: Watching episode {0} ({1}%)", episode.Title, progress);
     return true;
 }
Ejemplo n.º 3
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     // Follw.it doesn't require to send a status each X minutes or something
     return true;
 }
Ejemplo n.º 4
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     Log.Debug("WSD: Watching episode {0} ({1}%)", episode.Title, progress);
     return(true);
 }
Ejemplo n.º 5
0
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return(CallFollwitEpisode(episode, FollwitWatchStatus.Watched));
 }
Ejemplo n.º 6
0
 public TVEpisodeViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Episode = episode;
     _show = show;
     _season = season;
 }
Ejemplo n.º 7
0
 public TVSeasonViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, IEnumerable <WebTVEpisodeDetailed> episodes)
 {
     Show     = show;
     Season   = season;
     Episodes = episodes;
 }
Ejemplo n.º 8
0
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Start watching episode {0}, season {1}, show {2}", episode.Title, episode.SeasonId, episode.ShowId);
     return true;
 }
Ejemplo n.º 9
0
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Scrobble, 100);
 }
Ejemplo n.º 10
0
        private bool CallShowAPI(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeBasic episode, TraktWatchStatus state, int? progress)
        {
            var data = new TraktEpisodeScrobbleData()
            {
                MediaCenter = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion = TraktConfig.MediaCenterVersion,
                PluginVersion = TraktConfig.PluginVersion,
                Password = Configuration["passwordHash"],
                UserName = Configuration["username"],

                Duration = show.Runtime.ToString(),
                Episode = episode.EpisodeNumber.ToString(),
                Season = season.SeasonNumber.ToString(),
                Title = show.Title,
                Year = show.Year.ToString(),
            };

            if (progress != null)
                data.Progress = progress.Value.ToString();

            if (show.ExternalId.Count(x => x.Site == "IMDB") > 0)
                data.IMDBID = show.ExternalId.First(x => x.Site == "IMDB").Id;
            if (show.ExternalId.Count(x => x.Site == "TVDB") > 0)
                data.TVDBID = show.ExternalId.First(x => x.Site == "TVDB").Id;
            if (data.IMDBID == null && data.TVDBID == null)
            {
                Log.Info("Trakt: IMDB and TVDB unknown of episode {0}, not sending", episode.Title);
                return false;
            }

            try
            {
                Log.Debug("Trakt: calling service for show {0} (episode {1}) with progress {2} and state {3}", data.Title, episode.Title, data.Progress, state.ToString());
                TraktResponse response = TraktAPI.ScrobbleEpisode(data, state);
                if (response.Status != "success")
                {
                    Log.Warn("Trakt: failed to update watch status of episode '{0}' ({1}): {2}", episode.Title, episode.Id, response.Error);
                    return false;
                }
                Log.Trace("Trakt: finished service call");
                return true;
            }
            catch (Exception ex)
            {
                Log.Warn("Trakt: failed to call service", ex);
                return false;
            }
        }
Ejemplo n.º 11
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Watching, progress);
 }
Ejemplo n.º 12
0
        public override List <VideoInfo> GetVideos(Category category)
        {
            RssLink          cat        = category as RssLink;
            List <VideoInfo> returnList = new List <VideoInfo>();

            if (cat.Url.Equals("movies"))
            {
                WebBackendProvider provider = (WebBackendProvider)cat.Other;

                if (provider != null)
                {
                    WebMovieBasic[] movies = mediaAccess.GetMoviesBasic(provider.Id, true, null, MpExtendedService.WebSortField.Title, true, MpExtendedService.WebSortOrder.Asc, true);

                    foreach (WebMovieBasic m in movies)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = m.Id;
                        if (m.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Cover))
                        {
                            info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=4&offset=0&mediatype=0&maxWidth=160&maxHeight=160", mServer, mPort, m.Id, m.PID);
                        }
                        info.Other       = m;
                        info.Title       = m.Title;
                        info.Length      = new DateTime(TimeSpan.FromMinutes(m.Runtime).Ticks).ToString("HH:mm:ss");
                        info.Airdate     = m.Year.ToString();
                        info.Description =
                            (m.Genres != null && m.Genres.Length > 0 ? string.Format("\n{0}: {1}", Translation.Instance.Genre, string.Join(", ", m.Genres)) : "") +
                            (m.Actors != null && m.Actors.Length > 0 ? string.Format("\n{0}: {1}", Translation.Instance.Actors, string.Join(", ", m.Actors.Take(4).Select(a => a.Title).ToArray())) : "");
                        returnList.Add(info);
                    }
                }
            }
            else if (cat.Url.Equals("tvseason"))
            {
                WebTVSeasonDetailed season = (WebTVSeasonDetailed)cat.Other;

                if (season != null)
                {
                    WebTVEpisodeBasic[] episodes = mediaAccess.GetTVEpisodesBasicForSeason(season.PID, true, season.Id, MpExtendedService.WebSortField.TVEpisodeNumber, true, MpExtendedService.WebSortOrder.Asc, true);

                    foreach (WebTVEpisodeBasic e in episodes)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = e.Id;
                        if (e.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Banner))
                        {
                            info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=2&offset=0&mediatype=3&maxWidth=160&maxHeight=160", mServer, mPort, e.Id, e.PID);
                        }
                        if (e.RatingSpecified && e.Rating > 0.0f)
                        {
                            info.Description = string.Format("Rating: {0}", e.Rating);
                        }
                        info.Other   = e;
                        info.Title   = string.Format("s{0:D2}e{1:D2} - {2}", e.SeasonNumber, e.EpisodeNumber, e.Title);
                        info.Airdate = e.FirstAired.ToString("d", OnlineVideoSettings.Instance.Locale);

                        returnList.Add(info);
                    }
                }
            }
            else if (cat.Url.Equals("tvgroup"))
            {
                WebChannelGroup group = (WebChannelGroup)cat.Other;

                if (group != null)
                {
                    WebChannelDetailed[] channels = tvAccess.GetChannelsDetailed(group.Id, true, MpExtendedTvService.WebSortField.Channel, true, MpExtendedTvService.WebSortOrder.Asc, true);

                    foreach (var c in channels)
                    {
                        VideoInfo info = new VideoInfo();
                        info.VideoUrl = c.Id.ToString();
                        info.Other    = c;
                        info.Title    = string.Format("{0}{1}", c.Title, c.CurrentProgram != null ? " --- " + c.CurrentProgram.Title : "");
                        if (c.CurrentProgram != null)
                        {
                            info.Airdate     = string.Format("{0:t} - {1:t}", c.CurrentProgram.StartTime, c.CurrentProgram.EndTime);
                            info.Description = c.CurrentProgram.Description;
                            info.Length      = (c.CurrentProgram.DurationInMinutes * 60).ToString();
                        }
                        info.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&artworktype={3}&offset=0&mediatype={4}&maxWidth=160&maxHeight=160", mServer, mPort, c.Id, (int)MpExtendedStreamingService.WebFileType.Logo, (int)MpExtendedStreamingService.WebMediaType.TV);
                        returnList.Add(info);
                    }
                }
            }
            return(returnList);
        }
Ejemplo n.º 13
0
 public bool CancelWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Canceled episode {0}", episode.Title);
     return(true);
 }
Ejemplo n.º 14
0
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Finished episode {0}", episode.Title);
     return(true);
 }
Ejemplo n.º 15
0
 public bool CancelWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Canceled episode {0}", episode.Title);
     return true;
 }
Ejemplo n.º 16
0
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallShowAPI(show, season, episode, TraktWatchStatus.Watching, 0);
 }
Ejemplo n.º 17
0
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Finished episode {0}", episode.Title);
     return true;
 }
Ejemplo n.º 18
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     return(CallShowAPI(show, season, episode, TraktWatchStatus.Watching, progress));
 }
Ejemplo n.º 19
0
 public TVEpisodeViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Show    = show;
     Season  = season;
     Episode = episode;
 }
Ejemplo n.º 20
0
 public bool FinishEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return(CallShowAPI(show, season, episode, TraktWatchStatus.Scrobble, 100));
 }
Ejemplo n.º 21
0
 public TVSeasonViewModel(WebTVShowDetailed show, WebTVSeasonDetailed season, IEnumerable<WebTVEpisodeDetailed> episodes)
 {
     Show = show;
     Season = season;
     Episodes = episodes;
 }
Ejemplo n.º 22
0
 public bool CancelWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return(CallShowAPI(show, season, episode, TraktWatchStatus.CancelWatching, null));
 }
Ejemplo n.º 23
0
 public bool WatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode, int progress)
 {
     // Follw.it doesn't require to send a status each X minutes or something
     return(true);
 }
Ejemplo n.º 24
0
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return CallFollwitEpisode(episode, FollwitWatchStatus.Watching);
 }
Ejemplo n.º 25
0
 public bool CancelWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     return(CallFollwitEpisode(episode, FollwitWatchStatus.CancelWatching));
 }
Ejemplo n.º 26
0
 public bool StartWatchingEpisode(WebTVShowDetailed show, WebTVSeasonDetailed season, WebTVEpisodeDetailed episode)
 {
     Log.Debug("WSD: Start watching episode {0}, season {1}, show {2}", episode.Title, episode.SeasonId, episode.ShowId);
     return(true);
 }