Exemple #1
0
        public MockedDatabaseMovie(MediaLibraryMovie movie, int playPercentage)
        {
            IDictionary <Guid, IList <MediaItemAspect> > movieAspects = new Dictionary <Guid, IList <MediaItemAspect> >();
            MultipleMediaItemAspect resourceAspect = new MultipleMediaItemAspect(ProviderResourceAspect.Metadata);

            resourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, "c:\\" + movie.Title + ".mkv");
            MediaItemAspect.AddOrUpdateAspect(movieAspects, resourceAspect);
            MediaItemAspect.AddOrUpdateExternalIdentifier(movieAspects, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_MOVIE, movie.Imdb);
            MediaItemAspect.SetAttribute(movieAspects, MovieAspect.ATTR_MOVIE_NAME, movie.Title);

            SingleMediaItemAspect mediaItemAspect = new SingleMediaItemAspect(MediaAspect.Metadata);

            mediaItemAspect.SetAttribute(MediaAspect.ATTR_PLAYCOUNT, 1);
            mediaItemAspect.SetAttribute(MediaAspect.ATTR_LASTPLAYED, DateTime.Now);
            MediaItemAspect.SetAspect(movieAspects, mediaItemAspect);

            SingleMediaItemAspect importerAspect = new SingleMediaItemAspect(ImporterAspect.Metadata);

            importerAspect.SetAttribute(ImporterAspect.ATTR_DATEADDED, DateTime.Now);

            IDictionary <string, string> userData = new Dictionary <string, string>();

            userData.Add(UserDataKeysKnown.KEY_PLAY_PERCENTAGE, playPercentage.ToString());
            MediaItemAspect.SetAspect(movieAspects, importerAspect);

            Movie = new MediaItem(Guid.NewGuid(), movieAspects, userData);
        }
Exemple #2
0
        private bool MovieMatch(MediaItem localMovie, MediaLibraryMovie watchedRestoreMovie)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(watchedRestoreMovie.Imdb) && !string.IsNullOrEmpty(MediaItemAspectsUtl.GetMovieImdbId(localMovie)))
            {
                result = String.Compare(MediaItemAspectsUtl.GetMovieImdbId(localMovie), watchedRestoreMovie.Imdb, StringComparison.OrdinalIgnoreCase) == 0;
            }

            else if ((MediaItemAspectsUtl.GetMovieTmdbId(localMovie) != 0) && watchedRestoreMovie.Tmdb.HasValue)
            {
                result = MediaItemAspectsUtl.GetMovieTmdbId(localMovie) == watchedRestoreMovie.Tmdb.Value;
            }

            else if (String.Compare(MediaItemAspectsUtl.GetMovieTitle(localMovie), watchedRestoreMovie.Title, StringComparison.OrdinalIgnoreCase) == 0 &&
                     (MediaItemAspectsUtl.GetMovieYear(localMovie) == watchedRestoreMovie.Year))
            {
                result = true;
            }
            return(result);
        }
        public MockedDatabaseMovie(MediaLibraryMovie movie)
        {
            IDictionary <Guid, IList <MediaItemAspect> > movieAspects = new Dictionary <Guid, IList <MediaItemAspect> >();
            MultipleMediaItemAspect resourceAspect = new MultipleMediaItemAspect(ProviderResourceAspect.Metadata);

            resourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, "c:\\" + movie.Title + ".mkv");
            MediaItemAspect.AddOrUpdateAspect(movieAspects, resourceAspect);
            MediaItemAspect.AddOrUpdateExternalIdentifier(movieAspects, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_MOVIE, movie.Imdb);
            MediaItemAspect.SetAttribute(movieAspects, MovieAspect.ATTR_MOVIE_NAME, movie.Title);

            SingleMediaItemAspect mediaItemAspect = new SingleMediaItemAspect(MediaAspect.Metadata);

            mediaItemAspect.SetAttribute(MediaAspect.ATTR_PLAYCOUNT, movie.PlayCount);
            mediaItemAspect.SetAttribute(MediaAspect.ATTR_LASTPLAYED, DateTime.Parse(movie.LastPlayed));
            MediaItemAspect.SetAspect(movieAspects, mediaItemAspect);

            SingleMediaItemAspect importerAspect = new SingleMediaItemAspect(ImporterAspect.Metadata);

            importerAspect.SetAttribute(ImporterAspect.ATTR_DATEADDED, DateTime.Parse(movie.AddedToDb));
            MediaItemAspect.SetAspect(movieAspects, importerAspect);

            Movie = new MediaItem(Guid.NewGuid(), movieAspects);
        }