Esempio n. 1
0
        internal static WebMovieDetailed MovieDetailed(MediaItem item)
        {
            WebMovieBasic webMovieBasic = MovieBasic(item);

            MediaItemAspect movieAspect = MediaItemAspectExtensions.GetAspect(item, (MediaItemAspectMetadata)MovieAspect.Metadata);
            MediaItemAspect videoAspect = MediaItemAspectExtensions.GetAspect(item, (MediaItemAspectMetadata)VideoAspect.Metadata);
            IList <MultipleMediaItemAspect> audioAspects;
            List <string> languages = new List <string>();

            if (MediaItemAspect.TryGetAspects(item.Aspects, VideoAudioStreamAspect.Metadata, out audioAspects))
            {
                foreach (MultipleMediaItemAspect audioAspect in audioAspects)
                {
                    string language = audioAspect.GetAttributeValue <string>(VideoAudioStreamAspect.ATTR_AUDIOLANGUAGE);
                    if (!string.IsNullOrEmpty(language) && !languages.Contains(language))
                    {
                        languages.Add(language);
                    }
                }
            }

            WebMovieDetailed webMovieDetailed = new WebMovieDetailed
            {
                IsProtected = webMovieBasic.IsProtected,
                Type        = webMovieBasic.Type,
                Watched     = webMovieBasic.Watched,
                Runtime     = webMovieBasic.Runtime,
                DateAdded   = webMovieBasic.DateAdded,
                Id          = webMovieBasic.Id,
                PID         = webMovieBasic.PID,
                Title       = webMovieBasic.Title,
                ExternalId  = webMovieBasic.ExternalId,
                Rating      = webMovieBasic.Rating,
                Year        = webMovieBasic.Year,
                Actors      = webMovieBasic.Actors,
                Genres      = webMovieBasic.Genres,
                Path        = webMovieBasic.Path,
                Artwork     = webMovieBasic.Artwork,
                Tagline     = movieAspect.GetAttributeValue <string>(MovieAspect.ATTR_TAGLINE) ?? string.Empty,
                Summary     = videoAspect.GetAttributeValue <string>(VideoAspect.ATTR_STORYPLOT) ?? string.Empty,
                Language    = string.Join(", ", languages.ToArray())
            };

            IEnumerable <string> aspectWriters = videoAspect.GetCollectionAttribute <string>(VideoAspect.ATTR_WRITERS);

            if (aspectWriters != null)
            {
                webMovieDetailed.Writers = aspectWriters.Distinct().ToList();
            }

            IEnumerable <string> aspectDirectors = videoAspect.GetCollectionAttribute <string>(VideoAspect.ATTR_DIRECTORS);

            if (aspectDirectors != null)
            {
                webMovieDetailed.Directors = aspectDirectors.Distinct().ToList();
            }

            return(webMovieDetailed);
        }
Esempio n. 2
0
        internal static WebMovieBasic MovieBasic(MediaItem item)
        {
            MediaItemAspect movieAspect    = item.GetAspect(MovieAspect.Metadata);
            MediaItemAspect videoAspect    = item.GetAspect(VideoAspect.Metadata);
            MediaItemAspect mediaAspect    = item.GetAspect(MediaAspect.Metadata);
            MediaItemAspect importerAspect = item.GetAspect(ImporterAspect.Metadata);

            WebMovieBasic webMovieBasic = new WebMovieBasic
            {
                Title     = movieAspect.GetAttributeValue <string>(MovieAspect.ATTR_MOVIE_NAME),
                Id        = item.MediaItemId.ToString(),
                Type      = WebMediaType.Movie,
                Path      = ResourceAccessUtils.GetPaths(item),
                Year      = mediaAspect.GetAttributeValue <DateTime>(MediaAspect.ATTR_RECORDINGTIME).Year,
                Runtime   = movieAspect.GetAttributeValue <int>(MovieAspect.ATTR_RUNTIME_M),
                Watched   = Convert.ToInt32(item.UserData.FirstOrDefault(d => d.Key == UserDataKeysKnown.KEY_PLAY_PERCENTAGE).Value ?? "0") >= 100,
                DateAdded = importerAspect.GetAttributeValue <DateTime>(ImporterAspect.ATTR_DATEADDED),
                Rating    = Convert.ToSingle(movieAspect.GetAttributeValue <double>(MovieAspect.ATTR_TOTAL_RATING)),
                Artwork   = ResourceAccessUtils.GetWebArtwork(item),
            };

            IEnumerable <string> aspectActors = videoAspect.GetCollectionAttribute <string>(VideoAspect.ATTR_ACTORS);

            if (aspectActors != null)
            {
                webMovieBasic.Actors = aspectActors.Distinct().Select(a => new WebActor(a)).ToList();
            }

            IList <MediaItemAspect> genres;

            if (item.Aspects.TryGetValue(GenreAspect.ASPECT_ID, out genres))
            {
                webMovieBasic.Genres = genres.Select(g => g.GetAttributeValue <string>(GenreAspect.ATTR_GENRE)).ToList();
            }

            string tmdbId;

            if (MediaItemAspect.TryGetExternalAttribute(item.Aspects, ExternalIdentifierAspect.SOURCE_TMDB, ExternalIdentifierAspect.TYPE_MOVIE, out tmdbId) && tmdbId != null)
            {
                webMovieBasic.ExternalId.Add(new WebExternalId {
                    Site = "TMDB", Id = tmdbId
                });
            }
            string imdbId;

            if (MediaItemAspect.TryGetExternalAttribute(item.Aspects, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_MOVIE, out imdbId) && imdbId != null)
            {
                webMovieBasic.ExternalId.Add(new WebExternalId {
                    Site = "IMDB", Id = imdbId
                });
            }

            return(webMovieBasic);
        }
Esempio n. 3
0
        private bool CallMovieAPI(WebMovieBasic movie, TraktWatchStatus state, int?progress)
        {
            var data = new TraktMovieScrobbleData()
            {
                MediaCenter          = TraktConfig.MediaCenter,
                MediaCenterBuildDate = TraktConfig.MediaCenterDate,
                MediaCenterVersion   = TraktConfig.MediaCenterVersion,
                PluginVersion        = TraktConfig.PluginVersion,
                Password             = Configuration["passwordHash"],
                UserName             = Configuration["username"],

                Duration = movie.Runtime.ToString(),
                Title    = movie.Title,
                Year     = movie.Year.ToString()
            };

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

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

            try
            {
                Log.Debug("Trakt: calling service for movie {0} with progress {1} and state {2}", data.Title, data.Progress, state);
                TraktResponse response = TraktAPI.ScrobbleMovie(data, state);
                if (response.Status != "success")
                {
                    Log.Warn("Trakt: failed to update watch status of movie '{0}' ({1}): {2}", movie.Title, movie.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);
            }
        }
Esempio n. 4
0
        public override string GetVideoUrl(VideoInfo video)
        {
            var    type       = MpExtendedStreamingService.WebMediaType.File;
            int    providerId = 0;
            String itemId     = null;
            bool   live       = false;

            if (video.Other is WebMovieBasic)
            {
                WebMovieBasic movie = video.Other as WebMovieBasic;
                type       = MpExtendedStreamingService.WebMediaType.Movie;
                providerId = movie.PID;
                itemId     = movie.Id;
            }
            else if (video.Other is WebTVEpisodeBasic)
            {
                WebTVEpisodeBasic ep = video.Other as WebTVEpisodeBasic;
                type       = MpExtendedStreamingService.WebMediaType.TVEpisode;
                providerId = ep.PID;
                itemId     = ep.Id;
            }
            else if (video.Other is WebChannelDetailed)
            {
                WebChannelDetailed channel = video.Other as WebChannelDetailed;
                type       = MpExtendedStreamingService.WebMediaType.TV;
                providerId = 0;
                itemId     = channel.Id.ToString();
                live       = true;
            }

            if (mediaStreaming.AuthorizeStreaming().Result == true)
            {
                video.PlaybackOptions = new Dictionary <string, string>();
                foreach (var profile in mediaStreaming.GetTranscoderProfilesForTarget("pc-flash-video"))
                {
                    video.PlaybackOptions.Add(profile.Name, new MPUrlSourceFilter.HttpUrl(
                                                  string.Format("http://{0}:{1}/MPExtended/StreamingService/stream/DoStream?type={2}&provider={3}&itemId={4}&clientDescription={5}&profileName={6}&startPosition={7}",
                                                                mServer,
                                                                mPort,
                                                                (int)type,
                                                                providerId,
                                                                HttpUtility.UrlEncode(itemId),
                                                                HttpUtility.UrlEncode("OnlineVideos client"),
                                                                HttpUtility.UrlEncode(profile.Name), 0))
                                              /*{ LiveStream = live }*/.ToString());
                }
                return(video.PlaybackOptions.Select(p => p.Value).FirstOrDefault());
            }

            throw new OnlineVideosException("No authorization");
        }