/// <summary> /// Asynchronously tries to extract movie actors for the given <param name="mediaItemAccessor"></param> /// </summary> /// <param name="mediaItemAccessor">Points to the resource for which we try to extract metadata</param> /// <param name="extractedAspects">List of MediaItemAspect dictionaries to update with metadata</param> /// <returns><c>true</c> if metadata was found and stored into the <paramref name="extractedAspects"/>, else <c>false</c></returns> protected async Task <bool> TryExtractMovieActorsMetadataAsync(IResourceAccessor mediaItemAccessor, IList <IDictionary <Guid, IList <MediaItemAspect> > > extractedAspects, MovieInfo reimport) { NfoMovieReader movieNfoReader = await TryGetNfoMovieReaderAsync(mediaItemAccessor).ConfigureAwait(false); if (movieNfoReader != null) { if (reimport != null && !VerifyMovieReimport(movieNfoReader, reimport)) { return(false); } return(movieNfoReader.TryWriteActorMetadata(extractedAspects)); } return(false); }
public void TestNfoMovieReaderWriteActorMetadata() { //Arrange IList <PersonStub> actors = CreateTestActors(); MovieStub movieStub = CreateTestMovieStub(actors); NfoMovieReader reader = new NfoMovieReader(new ConsoleLogger(LogLevel.All, true), 1, true, false, false, null, new NfoMovieMetadataExtractorSettings()); reader.GetMovieStubs().Add(movieStub); //Act IList <IDictionary <Guid, IList <MediaItemAspect> > > aspects = new List <IDictionary <Guid, IList <MediaItemAspect> > >(); reader.TryWriteActorMetadata(aspects); //Assert Assert.AreEqual(2, aspects.Count); MediaItemAspect personAspect0 = MediaItemAspect.GetAspect(aspects[0], PersonAspect.Metadata); Assert.NotNull(personAspect0); Assert.AreEqual(actors[0].Name, personAspect0.GetAttributeValue <string>(PersonAspect.ATTR_PERSON_NAME)); Assert.AreEqual(actors[0].Biography, personAspect0.GetAttributeValue <string>(PersonAspect.ATTR_BIOGRAPHY)); Assert.AreEqual(actors[0].Birthdate, personAspect0.GetAttributeValue <DateTime?>(PersonAspect.ATTR_DATEOFBIRTH)); Assert.AreEqual(actors[0].Deathdate, personAspect0.GetAttributeValue <DateTime?>(PersonAspect.ATTR_DATEOFDEATH)); Assert.AreEqual(PersonAspect.OCCUPATION_ACTOR, personAspect0.GetAttributeValue <string>(PersonAspect.ATTR_OCCUPATION)); IList <MediaItemAspect> externalIdentifiers0; Assert.IsTrue(aspects[0].TryGetValue(ExternalIdentifierAspect.ASPECT_ID, out externalIdentifiers0)); Assert.IsTrue(TestUtils.HasExternalId(externalIdentifiers0, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_PERSON, actors[0].ImdbId)); MediaItemAspect personAspect1 = MediaItemAspect.GetAspect(aspects[1], PersonAspect.Metadata); Assert.NotNull(personAspect1); Assert.AreEqual(actors[1].Name, personAspect1.GetAttributeValue <string>(PersonAspect.ATTR_PERSON_NAME)); Assert.AreEqual(actors[1].Biography, personAspect1.GetAttributeValue <string>(PersonAspect.ATTR_BIOGRAPHY)); Assert.AreEqual(actors[1].Birthdate, personAspect1.GetAttributeValue <DateTime?>(PersonAspect.ATTR_DATEOFBIRTH)); Assert.AreEqual(actors[1].Deathdate, personAspect1.GetAttributeValue <DateTime?>(PersonAspect.ATTR_DATEOFDEATH)); Assert.AreEqual(PersonAspect.OCCUPATION_ACTOR, personAspect1.GetAttributeValue <string>(PersonAspect.ATTR_OCCUPATION)); IList <MediaItemAspect> externalIdentifiers1; Assert.IsTrue(aspects[1].TryGetValue(ExternalIdentifierAspect.ASPECT_ID, out externalIdentifiers1)); Assert.IsTrue(TestUtils.HasExternalId(externalIdentifiers1, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_PERSON, actors[1].ImdbId)); }