예제 #1
0
        /// <summary>
        /// Asynchronously tries to extract series metadata 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="extractedAspectData">Dictionary of MediaItemAspect to update with metadata</param>
        /// <param name="reimport">During reimport only allow if nfo is for same media as this</param>
        /// <returns><c>true</c> if metadata was found and stored into the <paramref name="extractedAspectData"/>, else <c>false</c></returns>
        protected async Task <bool> TryExtractAlbumMetadataAsync(IResourceAccessor mediaItemAccessor, IDictionary <Guid, IList <MediaItemAspect> > extractedAspectData, AlbumInfo reimport)
        {
            NfoAlbumReader albumNfoReader = await TryGetNfoAlbumReaderAsync(mediaItemAccessor).ConfigureAwait(false);

            if (albumNfoReader != null)
            {
                if (reimport != null && !VerifyAlbumReimport(albumNfoReader, reimport))
                {
                    return(false);
                }

                return(albumNfoReader.TryWriteMetadata(extractedAspectData));
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Verifies if the album being reimported matches the album in the nfo file
        /// </summary>
        /// <param name="reader">Reader used read the album information from the nfo file</param>
        /// <param name="reimport">The album being reimported</param>
        /// <returns>Result of the verification</returns>
        protected bool VerifyAlbumReimport(NfoAlbumReader reader, AlbumInfo reimport)
        {
            if (reimport == null)
            {
                return(true);
            }

            IDictionary <Guid, IList <MediaItemAspect> > aspectData = new Dictionary <Guid, IList <MediaItemAspect> >();

            if (reader.TryWriteMetadata(aspectData))
            {
                AlbumInfo info = new AlbumInfo();
                info.FromMetadata(aspectData);
                if (reimport.Equals(info))
                {
                    return(true);
                }
            }
            return(false);
        }