public TmdbPersonInfoCompletedEventArgs(
 TmdbPerson person,
 Exception e,
 bool canceled,
 object state)
     : base(e, canceled, state)
 {
     _person = person;
 }
Beispiel #2
0
        private Artist ConvertToArtist(TmdbPerson tmdbPerson)
        {
            // create the Artist from the tmdbPerson
            var artist = JsonConvert.DeserializeObject <Artist>(
                JsonConvert.SerializeObject(tmdbPerson, TmdbJsonSettings.Instance), TmdbJsonSettings.Instance);

            artist.Id        = nameof(Artist) + IdSeparator + artist.Id;
            artist.NickNames = tmdbPerson.AlsoKnownAs;

            // set images
            artist.MainImagePath = tmdbPerson.ProfilePath;

            // create the connections
            artist.Connections = new List <Connection>();

            foreach (var cast in tmdbPerson.CombinedCredits.Cast.Where(c => !string.IsNullOrEmpty(c.PosterPath)))
            {
                var id = cast.MediaType == "tv"
                    ? nameof(TvSeries) + IdSeparator + cast.Id
                    : nameof(Movie) + IdSeparator + cast.Id;

                artist.Connections.Add(new Connection
                {
                    ConnectedId = id,
                    Type        = ConnectionType.Actor,
                    Label       = cast.Character
                });
            }

            foreach (var cast in tmdbPerson.CombinedCredits.Crew.Where(c => !string.IsNullOrEmpty(c.PosterPath)))
            {
                ConnectionType type;
                if (_handledCrewJobs.TryGetValue(cast.Job, out type))
                {
                    artist.Connections.Add(new Connection
                    {
                        ConnectedId = nameof(Movie) + IdSeparator + cast.Id,
                        Type        = type,
                        Label       = cast.Job
                    });
                }
                else
                {
                    artist.Connections.Add(new Connection
                    {
                        ConnectedId = nameof(Movie) + IdSeparator + cast.Id,
                        Type        = ConnectionType.Crew,
                        Label       = cast.Job
                    });
                }
            }

            return(artist);
        }