Example #1
0
 protected void InitialiseProperties()
 {
     if (_configuration == null)
     {
         return;
     }
     if (_configuration.IsNative)
     {
         EmulatorType = EmulatorType.Native;
     }
     else if (_configuration.IsLibRetro)
     {
         EmulatorType = EmulatorType.LibRetro;
     }
     else
     {
         EmulatorType = EmulatorType.Emulator;
     }
     Name = _configuration.Name;
     if (!string.IsNullOrEmpty(_configuration.Path))
     {
         PathBrowser.ChoosenResourcePath = LocalFsResourceProviderBase.ToResourcePath(_configuration.Path);
     }
     Arguments              = _configuration.Arguments;
     WorkingDirectory       = _configuration.WorkingDirectory;
     UseQuotes              = _configuration.UseQuotes;
     ExitsOnEscapeKey       = _configuration.ExitsOnEscapeKey;
     FileExtensions         = new HashSet <string>(_configuration.FileExtensions);
     SelectedGameCategories = new List <string>(_configuration.Platforms);
     UpdateIsGameCategoriesSelected();
 }
Example #2
0
        protected void ImportRecording(string fileName)
        {
            ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>();
            IMediaLibrary   mediaLibrary   = ServiceRegistration.Get <IMediaLibrary>();

            List <Share> possibleShares = new List <Share>(); // Shares can point to different depth, we try to find the deepest one

            foreach (var share in mediaLibrary.GetShares(systemResolver.LocalSystemId).Values)
            {
                var dir = LocalFsResourceProviderBase.ToDosPath(share.BaseResourcePath.LastPathSegment.Path);
                if (dir != null && fileName.StartsWith(dir, StringComparison.InvariantCultureIgnoreCase))
                {
                    possibleShares.Add(share);
                }
            }
            if (possibleShares.Count == 0)
            {
                ServiceRegistration.Get <ILogger>().Warn("SlimTvService: Received notifaction of new recording but could not find a media source. Have you added recordings folder as media source? File: {0}", fileName);
                return;
            }

            Share           usedShare      = possibleShares.OrderByDescending(s => s.BaseResourcePath.LastPathSegment.Path.Length).First();
            IImporterWorker importerWorker = ServiceRegistration.Get <IImporterWorker>();

            importerWorker.ScheduleImport(LocalFsResourceProviderBase.ToResourcePath(fileName), usedShare.MediaCategories, false);
        }
        protected VideoDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> extractedMIATypeIds) : base(driveInfo)
        {
            IMediaAccessor    mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
            ResourcePath      rp            = LocalFsResourceProviderBase.ToResourcePath(driveInfo.Name);
            IResourceAccessor ra;

            if (!rp.TryCreateLocalResourceAccessor(out ra))
            {
                throw new ArgumentException(string.Format("Unable to access drive '{0}'", driveInfo.Name));
            }
            using (ra)
                _mediaItem = mediaAccessor.CreateLocalMediaItem(ra, mediaAccessor.GetMetadataExtractorsForMIATypes(extractedMIATypeIds));
            if (_mediaItem == null)
            {
                throw new Exception(string.Format("Could not create media item for drive '{0}'", driveInfo.Name));
            }

            MatchWithStubs(driveInfo, new MediaItem[] { _mediaItem });
            IEnumerable <MediaItem> processedItems = CertificationHelper.ProcessMediaItems(new MediaItem[] { _mediaItem });

            if (processedItems.Count() == 0)
            {
                _mediaItem = null;
                return;
            }
            _mediaItem = processedItems.First();
            SingleMediaItemAspect mia = null;

            MediaItemAspect.TryGetAspect(_mediaItem.Aspects, MediaAspect.Metadata, out mia);
            mia.SetAttribute(MediaAspect.ATTR_TITLE, mia.GetAttributeValue(MediaAspect.ATTR_TITLE) +
                             " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")");
        }
            public IList <Guid> Execute(IList <string> mediaFiles, ShareLocation shareLocation)
            {
                NumFiles = mediaFiles.Count;
                IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
                IContentDirectory        cd  = scm.ContentDirectory;
                string systemId = shareLocation == ShareLocation.Local ? ServiceRegistration.Get <ISystemResolver>().LocalSystemId : scm.HomeServerSystemId;

                Guid[] necessaryAudioAspectIds = null;
                Guid[] optionalAudioAspectIds  = null;

                ILogger        logger        = ServiceRegistration.Get <ILogger>();
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                Guid?          dialogId      = screenManager.ShowDialog(Consts.DIALOG_IMPORT_PLAYLIST_PROGRESS, (dialogName, dialogInstanceId) => Cancel());

                if (!dialogId.HasValue)
                {
                    logger.Warn("ImportPlaylistOperation: Error showing progress dialog");
                    return(null);
                }

                IList <Guid> result = new List <Guid>();

                NumMatched   = 0;
                NumProcessed = 0;
                NumMatched   = 0;
                UpdateScreenData();
                try
                {
                    foreach (string localMediaFile in mediaFiles)
                    {
                        if (IsCancelled)
                        {
                            return(null);
                        }
                        CheckUpdateScreenData();
                        MediaItem item = cd.LoadItem(systemId, LocalFsResourceProviderBase.ToResourcePath(localMediaFile), necessaryAudioAspectIds, optionalAudioAspectIds);
                        NumProcessed++;
                        if (item == null)
                        {
                            logger.Warn("ImportPlaylistOperation: Media item '{0}' was not found in the media library", localMediaFile);
                            continue;
                        }
                        logger.Debug("ImportPlaylistOperation: Matched media item '{0}' in media library", localMediaFile);
                        NumMatched++;
                        result.Add(item.MediaItemId);
                    }
                }
                catch (Exception e)
                {
                    logger.Warn("ImportPlaylistOperation: Error importing playlist", e);
                }
                screenManager.CloseDialog(dialogId.Value);
                return(result);
            }
Example #5
0
        /// <summary>
        /// Detects if the given directory contains video, image or audio media files and returns <see cref="MediaItem"/> instances for those files.
        /// </summary>
        /// <param name="directory">The directory to be examined.</param>
        /// <param name="videoMIATypeIds">Ids of the media item aspects to be extracted from video items.</param>
        /// <param name="imageMIATypeIds">Ids of the media item aspects to be extracted from image items.</param>
        /// <param name="audioMIATypeIds">Ids of the media item aspects to be extracted from audio items.</param>
        /// if the return value is <see cref="MultiMediaType.None"/>.</param>
        /// <returns>Type of media items found.</returns>
        public static MultiMediaType DetectMultimedia(string directory,
                                                      IEnumerable <Guid> videoMIATypeIds, IEnumerable <Guid> imageMIATypeIds, IEnumerable <Guid> audioMIATypeIds)
        {
            if (!Directory.Exists(directory))
            {
                return(MultiMediaType.None);
            }

            return(DetectMultimedia(LocalFsResourceProviderBase.ToResourcePath(directory),
                                    videoMIATypeIds, imageMIATypeIds, audioMIATypeIds));
        }
Example #6
0
        protected void OnCoreItemSelectionChanged(AbstractProperty property, object oldValue)
        {
            ListItem selected = _localCoreItems.FirstOrDefault(i => i.Selected);

            if (selected == null)
            {
                return;
            }
            ResourcePath path = LocalFsResourceProviderBase.ToResourcePath(selected.Label(Consts.KEY_PATH, null).Evaluate());

            _emulatorProxy.PathBrowser.ChoosenResourcePath = path;
        }
        public static MediaItem CreateMediaItem(string filename)
        {
            IMediaAccessor     mediaAccessor   = ServiceRegistration.Get <IMediaAccessor>();
            IEnumerable <Guid> meIds           = mediaAccessor.GetMetadataExtractorsForMIATypes(NECESSARY_VIDEO_MIAS);
            ResourceLocator    resourceLocator = new ResourceLocator(LocalFsResourceProviderBase.ToResourcePath(filename));
            IResourceAccessor  ra = resourceLocator.CreateAccessor();

            if (ra == null)
            {
                return(null);
            }
            using (ra)
                return(mediaAccessor.CreateLocalMediaItem(ra, meIds));
        }
        protected VideoDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> extractedMIATypeIds) : base(driveInfo)
        {
            IMediaAccessor    mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
            ResourcePath      rp            = LocalFsResourceProviderBase.ToResourcePath(driveInfo.Name);
            IResourceAccessor ra;

            if (!rp.TryCreateLocalResourceAccessor(out ra))
            {
                throw new ArgumentException(string.Format("Unable to access drive '{0}'", driveInfo.Name));
            }
            using (ra)
                _mediaItem = mediaAccessor.CreateLocalMediaItem(ra, mediaAccessor.GetMetadataExtractorsForMIATypes(extractedMIATypeIds));
            if (_mediaItem == null)
            {
                throw new Exception(string.Format("Could not create media item for drive '{0}'", driveInfo.Name));
            }
            MediaItemAspect mia = _mediaItem.Aspects[MediaAspect.ASPECT_ID];

            mia.SetAttribute(MediaAspect.ATTR_TITLE, mia.GetAttributeValue(MediaAspect.ATTR_TITLE) +
                             " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")");
        }
Example #9
0
        public void TestExternalMediaItem()
        {
            MockDBUtils.Reset();
            MockCore.SetupLibrary();

            SingleTestMIA mia1 = TestCommonUtils.CreateSingleMIA("SINGLE1", Cardinality.Inline, true, true);

            MockCore.Management.AddMediaItemAspectStorage(mia1.Metadata);

            MockCore.Management.AddMediaItemAspectStorage(ProviderResourceAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ImporterAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ExternalIdentifierAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(MediaAspect.Metadata);

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

            SingleMediaItemAspect aspect1 = new SingleMediaItemAspect(mia1.Metadata);

            aspect1.SetAttribute(mia1.ATTR_INTEGER, 1);
            aspect1.SetAttribute(mia1.ATTR_STRING, "one");
            MediaItemAspect.SetAspect(aspects, aspect1);

            MediaItemAspect.AddOrUpdateExternalIdentifier(aspects, "test", ExternalIdentifierAspect.TYPE_EPISODE, "123");
            MediaItemAspect.AddOrUpdateExternalIdentifier(aspects, "test", ExternalIdentifierAspect.TYPE_SERIES, "456");

            MockDBUtils.AddReader(1, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");
            MockDBUtils.AddReader(2, "SELECT T5.MEDIA_ITEM_ID A23, T0.MEDIA_ITEM_ID A24, T1.MEDIA_ITEM_ID A25, T2.MEDIA_ITEM_ID A26, T3.MEDIA_ITEM_ID A27, T4.MEDIA_ITEM_ID A28, T0.ATTR_STRING A0, " +
                                  "T0.ATTR_INTEGER A1, T1.SYSTEM_ID A2, T1.RESOURCEINDEX A3, T1.ISPRIMARY A4, T1.MIMETYPE A5, T1.SIZE A6, T1.PATH A7, T1.PARENTDIRECTORY A8, T2.LASTIMPORTDATE A9, T2.DIRTY A10, T2.DATEADDED A11, " +
                                  "T3.SOURCE A12, T3.TYPE A13, T3.ID A14, T4.TITLE A15, T4.SORTTITLE A16, T4.RECORDINGTIME A17, T4.RATING A18, T4.COMMENT A19, T4.PLAYCOUNT A20, T4.LASTPLAYED A21, T4.ISVIRTUAL A22 FROM MEDIA_ITEMS T5 " +
                                  "LEFT OUTER JOIN M_SINGLE1 T0 ON T0.MEDIA_ITEM_ID = T5.MEDIA_ITEM_ID LEFT OUTER JOIN M_PROVIDERRESOURCE T1 ON T1.MEDIA_ITEM_ID = T5.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_IMPORTEDITEM T2 ON T2.MEDIA_ITEM_ID = T5.MEDIA_ITEM_ID LEFT OUTER JOIN M_EXTERNALIDENTIFIER T3 ON T3.MEDIA_ITEM_ID = T5.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_MEDIAITEM T4 ON T4.MEDIA_ITEM_ID = T5.MEDIA_ITEM_ID  WHERE T5.MEDIA_ITEM_ID = @V0", "@V0");

            string       pathStr = "c:\\item.mp3";
            ResourcePath path    = LocalFsResourceProviderBase.ToResourcePath(pathStr);

            MockCore.Library.AddOrUpdateMediaItem(Guid.Empty, null, path, aspects.Values.SelectMany(x => x), false);

            MockCore.ShutdownLibrary();
        }
Example #10
0
        public void OpenSelectUserImageDialog()
        {
            string imageFilename = _imagePath;
            string initialPath   = string.IsNullOrEmpty(imageFilename) ? null : DosPathHelper.GetDirectory(imageFilename);
            Guid   dialogHandle  = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Consts.RES_SELECT_USER_IMAGE, true, false,
                                                                                            string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                            path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(IsValidImage(choosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                ImagePath = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            }, null);
        }
Example #11
0
        public void TestEditBigMediaItem()
        {
            MockDBUtils.Reset();
            MockCore.SetupLibrary();

            SingleTestMIA mia1 = TestCommonUtils.CreateSingleMIA("SINGLE1", Cardinality.Inline, true, true);

            MockCore.Management.AddMediaItemAspectStorage(mia1.Metadata);

            MultipleTestMIA mia2 = TestCommonUtils.CreateMultipleMIA("MULTIPLE2", Cardinality.Inline, true, false);

            MockCore.Management.AddMediaItemAspectStorage(mia2.Metadata);

            MultipleTestMIA mia3 = TestCommonUtils.CreateMultipleMIA("MULTIPLE3", Cardinality.Inline, false, true);

            MockCore.Management.AddMediaItemAspectStorage(mia3.Metadata);

            SingleTestMIA mia4 = TestCommonUtils.CreateSingleMIA("SINGLE4", Cardinality.Inline, true, true);

            MockCore.Management.AddMediaItemAspectStorage(mia4.Metadata);

            MockCore.Management.AddMediaItemAspectStorage(ProviderResourceAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ImporterAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(MediaAspect.Metadata);

            IList <MediaItemAspect> aspects = new List <MediaItemAspect>();

            SingleMediaItemAspect aspect1 = new SingleMediaItemAspect(mia1.Metadata);

            aspect1.SetAttribute(mia1.ATTR_INTEGER, 1);
            aspect1.SetAttribute(mia1.ATTR_STRING, "one");
            aspects.Add(aspect1);

            MultipleMediaItemAspect aspect2_1 = new MultipleMediaItemAspect(mia2.Metadata);

            aspect2_1.SetAttribute(mia2.ATTR_ID, "2_1");
            aspect2_1.SetAttribute(mia2.ATTR_STRING, "two.one");
            aspects.Add(aspect2_1);
            MultipleMediaItemAspect aspect2_2 = new MultipleMediaItemAspect(mia2.Metadata);

            aspect2_2.SetAttribute(mia2.ATTR_ID, "2_2");
            aspect2_2.SetAttribute(mia2.ATTR_STRING, "two.two");
            aspects.Add(aspect2_2);

            MultipleMediaItemAspect aspect3_1 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_1.SetAttribute(mia3.ATTR_ID, "3_1");
            aspect3_1.SetAttribute(mia3.ATTR_INTEGER, 31);
            aspects.Add(aspect3_1);
            MultipleMediaItemAspect aspect3_2 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_2.SetAttribute(mia3.ATTR_ID, "3_2");
            aspect3_2.SetAttribute(mia3.ATTR_INTEGER, 32);
            aspects.Add(aspect3_2);
            MultipleMediaItemAspect aspect3_3 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_3.Deleted = true;
            aspect3_3.SetAttribute(mia3.ATTR_INTEGER, 33);
            aspects.Add(aspect3_3);

            Guid itemId = new Guid("aaaaaaaa-1111-1111-1111-aaaaaaaaaaaa");

            MockReader resourceReader = MockDBUtils.AddReader(1, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");

            resourceReader.AddResult(itemId);

            DateTime importDate;

            DateTime.TryParse("2014-10-11 12:34:56", out importDate);
            MockReader importReader = MockDBUtils.AddReader(2, "SELECT LASTIMPORTDATE A0, DIRTY A1, DATEADDED A2 FROM M_IMPORTEDITEM WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "A0", "A1", "A2");

            importReader.AddResult(importDate, "false", importDate);

            string     pathStr   = @"c:\item.mp3";
            MockReader mraReader = MockDBUtils.AddReader(3, "SELECT SYSTEM_ID A0, RESOURCEINDEX A1, ISPRIMARY A2, MIMETYPE A3, SIZE A4, PATH A5, PARENTDIRECTORY A6 FROM M_PROVIDERRESOURCE WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "MEDIA_ITEM_ID");

            mraReader.AddResult("00000000-0000-0000-0000-000000000000", 0, true, "audio/mp3", 100, pathStr, Guid.Empty);

            MockReader mia1Reader = MockDBUtils.AddReader(4, "SELECT MEDIA_ITEM_ID FROM M_SINGLE1 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "MEDIA_ITEM_ID");

            mia1Reader.AddResult(itemId);

            MockReader mia2Reader1 = MockDBUtils.AddReader(5, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE2 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");

            mia2Reader1.AddResult(itemId, "1_1");

            MockReader mia2Reader2 = MockDBUtils.AddReader(6, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE2 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");

            mia2Reader2.AddResult(itemId, "1_1");

            MockDBUtils.AddReader(7, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE2 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");
            MockDBUtils.AddReader(8, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE2 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");
            MockDBUtils.AddReader(9, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE3 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");
            MockDBUtils.AddReader(10, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE3 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");

            MockDBUtils.AddReader(11, "SELECT T7.MEDIA_ITEM_ID A26, T0.MEDIA_ITEM_ID A27, T1.MEDIA_ITEM_ID A28, T2.MEDIA_ITEM_ID A29, T3.MEDIA_ITEM_ID A30, T4.MEDIA_ITEM_ID A31, " +
                                  "T5.MEDIA_ITEM_ID A32, T6.MEDIA_ITEM_ID A33, T0.ATTR_STRING A0, T0.ATTR_INTEGER A1, T1.ATTR_ID A2, T1.ATTR_STRING A3, T2.ATTR_ID A4, T2.ATTR_INTEGER A5, T3.ATTR_STRING A6, " +
                                  "T3.ATTR_INTEGER A7, T4.SYSTEM_ID A8, T4.RESOURCEINDEX A9, T4.ISPRIMARY A10, T4.MIMETYPE A11, T4.SIZE A12, T4.PATH A13, T4.PARENTDIRECTORY A14, T5.LASTIMPORTDATE A15, T5.DIRTY A16, " +
                                  "T5.DATEADDED A17, T6.TITLE A18, T6.SORTTITLE A19, T6.RECORDINGTIME A20, T6.RATING A21, T6.COMMENT A22, T6.PLAYCOUNT A23, T6.LASTPLAYED A24, T6.ISVIRTUAL A25 FROM MEDIA_ITEMS T7 " +
                                  "LEFT OUTER JOIN M_SINGLE1 T0 ON T0.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID LEFT OUTER JOIN M_MULTIPLE2 T1 ON T1.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_MULTIPLE3 T2 ON T2.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID LEFT OUTER JOIN M_SINGLE4 T3 ON T3.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_PROVIDERRESOURCE T4 ON T4.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID LEFT OUTER JOIN M_IMPORTEDITEM T5 ON T5.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_MEDIAITEM T6 ON T6.MEDIA_ITEM_ID = T7.MEDIA_ITEM_ID  WHERE T7.MEDIA_ITEM_ID = @V0", "V0");

            ResourcePath path = LocalFsResourceProviderBase.ToResourcePath(pathStr);

            MockCore.Library.AddOrUpdateMediaItem(Guid.Empty, null, path, aspects, true);

            MockCore.ShutdownLibrary();
        }
Example #12
0
        public void ShowWorkingDirectoryDialog()
        {
            string       workingDirectory = WorkingDirectory;
            ResourcePath initialPath      = string.IsNullOrEmpty(workingDirectory) ? null : LocalFsResourceProviderBase.ToResourcePath(workingDirectory);
            Guid         dialogHandle     = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser("[Emulators.Config.WorkingDirectory.Label]", false, false, initialPath,
                                                                                                     path =>
            {
                string chosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                return(!string.IsNullOrEmpty(chosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }
            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, chosenPath => WorkingDirectory = LocalFsResourceProviderBase.ToDosPath(chosenPath), null);
        }
Example #13
0
        public void TestReconcileMediaItem()
        {
            //TODO: Update below code to work with ML changes
            return;

            MockCore.SetupLibrary(true);

            ServiceRegistration.Set <IPluginManager>(new MockPluginManager());

            MockRelationshipExtractor extractor = new MockRelationshipExtractor();

            MockMediaAccessor accessor = new MockMediaAccessor();

            accessor.AddRelationshipExtractor(extractor);
            ServiceRegistration.Set <IMediaAccessor>(accessor);
            ServiceRegistration.Get <IMediaAccessor>().Initialize();

            MockCore.Management.AddMediaItemAspectStorage(EpisodeAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ExternalIdentifierAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ImporterAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(MediaAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ProviderResourceAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(RelationshipAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(SeasonAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(SeriesAspect.Metadata);

            Guid episodeItemId = new Guid("aaaaaaaa-1111-1111-1111-aaaaaaaaaaaa");
            Guid seasonItemId  = new Guid("bbbbbbbb-2222-2222-2222-bbbbbbbbbbbb");
            Guid seriesItemId  = new Guid("cccccccc-3333-3333-3333-cccccccccccc");

            string seriesName        = "The Series";
            string seriesDescription = "The adventures of some characters";

            int    episode           = 1;
            string episodeName       = "The Episode";
            string episodeTitle      = seriesName + ": " + episodeName;
            Guid   parentDirectoryId = new Guid("dddddddd-4444-4444-4444-dddddddddddd");

            int    season            = 2;
            string seriesSeasonName  = seriesName + " " + season;
            string seasonDescription = "Continuing adventures of some characters, several story arcs etc";

            string externalSource   = "TEST";
            string externalSeriesId = "345";

            MockCore.Library.AddMediaItemId(episodeItemId);
            MockCore.Library.AddMediaItemId(seasonItemId);
            MockCore.Library.AddMediaItemId(seriesItemId);

            string       systemId = "local";
            string       mimeType = "video/mkv";
            string       pathStr  = @"c:\item.mkv";
            ResourcePath path     = LocalFsResourceProviderBase.ToResourcePath(pathStr);
            DateTime     importDate;

            DateTime.TryParse("2014-10-11 12:34:56", out importDate);

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

            MediaItemAspect.SetAttribute(episodeAspects, MediaAspect.ATTR_TITLE, episodeTitle);
            MediaItemAspect.SetCollectionAttribute(episodeAspects, EpisodeAspect.ATTR_EPISODE, new[] { episode });
            MediaItemAspect.SetAttribute(episodeAspects, EpisodeAspect.ATTR_SEASON, season);
            MultipleMediaItemAspect providerResourceAspect = MediaItemAspect.CreateAspect(episodeAspects, ProviderResourceAspect.Metadata);

            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_MIME_TYPE, mimeType);
            MediaItemAspect.AddOrUpdateExternalIdentifier(episodeAspects, externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);
            ServiceRegistration.Get <ILogger>().Debug("Episode:");
            MockCore.ShowMediaAspects(episodeAspects, MockCore.Library.GetManagedMediaItemAspectMetadata());

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

            MediaItemAspect.SetAttribute(seasonAspects, SeasonAspect.ATTR_SERIES_NAME, seriesName);
            MediaItemAspect.SetAttribute(seasonAspects, SeasonAspect.ATTR_SEASON, season);
            MediaItemAspect.SetAttribute(seasonAspects, SeasonAspect.ATTR_DESCRIPTION, seasonDescription);
            MediaItemAspect.AddOrUpdateExternalIdentifier(seasonAspects, externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);
            ServiceRegistration.Get <ILogger>().Debug("Season:");
            MockCore.ShowMediaAspects(seasonAspects, MockCore.Library.GetManagedMediaItemAspectMetadata());

            Guid[] matchAspects = new[] { SeasonAspect.ASPECT_ID, ExternalIdentifierAspect.ASPECT_ID, MediaAspect.ASPECT_ID };
            extractor.AddRelationship(EpisodeAspect.ROLE_EPISODE, new[] { EpisodeAspect.ASPECT_ID }, SeasonAspect.ROLE_SEASON, new[] { SeasonAspect.ASPECT_ID }, matchAspects, externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId, new List <IDictionary <Guid, IList <MediaItemAspect> > >()
            {
                seasonAspects
            }, EpisodeSeasonMatcher, episode);

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

            MediaItemAspect.SetAttribute(seriesAspects, SeasonAspect.ATTR_SERIES_NAME, seriesName);
            MediaItemAspect.SetAttribute(seriesAspects, SeasonAspect.ATTR_DESCRIPTION, seriesDescription);
            MediaItemAspect.AddOrUpdateExternalIdentifier(seriesAspects, externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);
            ServiceRegistration.Get <ILogger>().Debug("Series:");
            MockCore.ShowMediaAspects(seriesAspects, MockCore.Library.GetManagedMediaItemAspectMetadata());

            matchAspects = new[] { SeriesAspect.ASPECT_ID, ExternalIdentifierAspect.ASPECT_ID, MediaAspect.ASPECT_ID };
            extractor.AddRelationship(SeasonAspect.ROLE_SEASON, new[] { SeasonAspect.ASPECT_ID }, SeriesAspect.ROLE_SERIES, new[] { SeriesAspect.ASPECT_ID }, matchAspects, externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId, new List <IDictionary <Guid, IList <MediaItemAspect> > >()
            {
                seriesAspects
            }, null, season);

            MockDBUtils.AddReader(1, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");

            MockDBUtils.AddReader(2, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "MEDIA_ITEM_ID");

            // Readers used by UpdateRelationships to find episode item

            MockReader reader2 = MockDBUtils.AddReader(3,
                                                       "SELECT T6.MEDIA_ITEM_ID A30, T0.MEDIA_ITEM_ID A31, T1.MEDIA_ITEM_ID A32, T2.MEDIA_ITEM_ID A33, T3.MEDIA_ITEM_ID A34, T4.MEDIA_ITEM_ID A35, T5.MEDIA_ITEM_ID A36, " +
                                                       "T0.SERIESNAME A0, T0.SEASON A1, T0.SERIESSEASONNAME A2, T0.EPISODENAME A3, T0.FIRSTAIRED A4, T0.TOTALRATING A5, T0.RATINGCOUNT A6, " +
                                                       "T1.LASTIMPORTDATE A7, T1.DIRTY A8, T1.DATEADDED A9, " +
                                                       "T2.TITLE A10, T2.RECORDINGTIME A11, T2.RATING A12, T2.COMMENT A13, T2.PLAYCOUNT A14, T2.LASTPLAYED A15, " +
                                                       "T3.SYSTEM_ID A16, T3.MIMETYPE A17, T3.SIZE A18, T3.PATH A19, T3.PARENTDIRECTORY A20, " +
                                                       "T4.SERIESNAME_0 A21, T4.SEASON_0 A22, T4.SERIESSEASONNAME_0 A23, T4.DESCRIPTION A24, T4.FIRSTAIRED_0 A25, T4.TOTALRATING_0 A26, T4.RATINGCOUNT_0 A27, " +
                                                       "T5.SERIESNAME_1 A28, T5.DESCRIPTION_0 A29 " +
                                                       "FROM MEDIA_ITEMS T6 " +
                                                       "LEFT OUTER JOIN M_EPISODEITEM T0 ON T0.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                       "LEFT OUTER JOIN M_IMPORTEDITEM T1 ON T1.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                       "LEFT OUTER JOIN M_MEDIAITEM T2 ON T2.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                       "LEFT OUTER JOIN M_PROVIDERRESOURCE T3 ON T3.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                       "LEFT OUTER JOIN M_SEASONITEM T4 ON T4.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                       "LEFT OUTER JOIN M_SERIESITEM T5 ON T5.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID  " +
                                                       "WHERE T6.MEDIA_ITEM_ID = @V0",
                                                       CreateAttributeIdList(30, 36));

            reader2.AddResult(
                episodeItemId, episodeItemId, episodeItemId, episodeItemId, episodeItemId, null, null,
                null, season, null, null, null, null, null,
                importDate, false, importDate,
                episodeTitle, null, null, null, null, null,
                systemId, mimeType, 100, @"c:\", parentDirectoryId,
                null, null, null, null, null, null, null,
                null, null
                );

            MockReader reader3 = MockDBUtils.AddReader(4,
                                                       "SELECT T0.MEDIA_ITEM_ID A0, " +
                                                       "T1.VALUE A1 " +
                                                       "FROM NM_EPISODE T0 " +
                                                       "INNER JOIN V_EPISODE T1 ON T0.VALUE_ID = T1.VALUE_ID " +
                                                       "WHERE T0.MEDIA_ITEM_ID = @V0",
                                                       "A0", "A1");

            reader3.AddResult(
                episodeItemId,
                episode);

            MockDBUtils.AddReader(5, "SELECT T0.MEDIA_ITEM_ID A0, T1.VALUE A1 FROM NM_DVDEPISODE T0 INNER JOIN V_DVDEPISODE T1 ON T0.VALUE_ID = T1.VALUE_ID WHERE T0.MEDIA_ITEM_ID = @V0", "A0", "A1");

            MockReader reader5 = MockDBUtils.AddReader(6,
                                                       "SELECT T0.MEDIA_ITEM_ID A3, T0.MEDIA_ITEM_ID A4, " +
                                                       "T0.SOURCE A0, T0.TYPE A1, T0.ID A2 " +
                                                       "FROM M_EXTERNALIDENTIFIER T0  " +
                                                       "WHERE T0.MEDIA_ITEM_ID = @V0",
                                                       CreateAttributeIdList(3, 4));

            reader5.AddResult(
                episodeItemId, episodeItemId,
                externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);

            MockDBUtils.AddReader(7,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, " +
                                  "T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 " +
                                  "FROM M_RELATIONSHIP T0  " +
                                  "WHERE T0.MEDIA_ITEM_ID = @V0",
                                  CreateAttributeIdList(3, 4));

            MockDBUtils.AddReader(8,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 FROM M_RELATIONSHIP T0  WHERE T0.LINKEDID IN (@V0)");

            // Readers used by UpdateRelationships to find season item

            MockDBUtils.AddReader(9,
                                  "SELECT T0.MEDIA_ITEM_ID A30, T0.MEDIA_ITEM_ID A31, T1.MEDIA_ITEM_ID A32, T2.MEDIA_ITEM_ID A33, T3.MEDIA_ITEM_ID A34, T4.MEDIA_ITEM_ID A35, T5.MEDIA_ITEM_ID A36, " +
                                  "T0.SERIESNAME_0 A0, T0.SEASON_0 A1, T0.SERIESSEASONNAME_0 A2, T0.DESCRIPTION A3, T0.FIRSTAIRED_0 A4, T0.TOTALRATING_0 A5, T0.RATINGCOUNT_0 A6, " +
                                  "T1.TITLE A7, T1.RECORDINGTIME A8, T1.RATING A9, T1.COMMENT A10, T1.PLAYCOUNT A11, T1.LASTPLAYED A12, " +
                                  "T2.SERIESNAME A13, T2.SEASON A14, T2.SERIESSEASONNAME A15, T2.EPISODENAME A16, T2.FIRSTAIRED A17, T2.TOTALRATING A18, T2.RATINGCOUNT A19, " +
                                  "T3.LASTIMPORTDATE A20, T3.DIRTY A21, T3.DATEADDED A22, " +
                                  "T4.SYSTEM_ID A23, T4.MIMETYPE A24, T4.SIZE A25, T4.PATH A26, T4.PARENTDIRECTORY A27, " +
                                  "T5.SERIESNAME_1 A28, T5.DESCRIPTION_0 A29 " +
                                  "FROM M_SEASONITEM T0 " +
                                  "INNER JOIN M_MEDIAITEM T1 ON T1.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_EPISODEITEM T2 ON T2.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_IMPORTEDITEM T3 ON T3.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_PROVIDERRESOURCE T4 ON T4.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_SERIESITEM T5 ON T5.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID  " +
                                  "WHERE T0.MEDIA_ITEM_ID IN(SELECT MEDIA_ITEM_ID FROM M_EXTERNALIDENTIFIER WHERE SOURCE = @V0 AND TYPE = @V1 AND ID = @V2)",
                                  CreateAttributeIdList(30, 36));

            MockDBUtils.AddReader(10, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");

            MockReader reader10 = MockDBUtils.AddReader(11,
                                                        "SELECT T6.MEDIA_ITEM_ID A30, T0.MEDIA_ITEM_ID A31, T1.MEDIA_ITEM_ID A32, T2.MEDIA_ITEM_ID A33, T3.MEDIA_ITEM_ID A34, T4.MEDIA_ITEM_ID A35, T5.MEDIA_ITEM_ID A36, " +
                                                        "T0.SERIESNAME A0, T0.SEASON A1, T0.SERIESSEASONNAME A2, T0.EPISODENAME A3, T0.FIRSTAIRED A4, T0.TOTALRATING A5, T0.RATINGCOUNT A6, " +
                                                        "T1.LASTIMPORTDATE A7, T1.DIRTY A8, T1.DATEADDED A9, " +
                                                        "T2.TITLE A10, T2.RECORDINGTIME A11, T2.RATING A12, T2.COMMENT A13, T2.PLAYCOUNT A14, T2.LASTPLAYED A15, " +
                                                        "T3.SYSTEM_ID A16, T3.MIMETYPE A17, T3.SIZE A18, T3.PATH A19, T3.PARENTDIRECTORY A20, " +
                                                        "T4.SERIESNAME_0 A21, T4.SEASON_0 A22, T4.SERIESSEASONNAME_0 A23, T4.DESCRIPTION A24, T4.FIRSTAIRED_0 A25, T4.TOTALRATING_0 A26, T4.RATINGCOUNT_0 A27, " +
                                                        "T5.SERIESNAME_1 A28, T5.DESCRIPTION_0 A29 " +
                                                        "FROM MEDIA_ITEMS T6 " +
                                                        "LEFT OUTER JOIN M_EPISODEITEM T0 ON T0.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_IMPORTEDITEM T1 ON T1.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_MEDIAITEM T2 ON T2.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_PROVIDERRESOURCE T3 ON T3.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_SEASONITEM T4 ON T4.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_SERIESITEM T5 ON T5.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID  " +
                                                        "WHERE T6.MEDIA_ITEM_ID = @V0",
                                                        CreateAttributeIdList(30, 36));

            reader10.AddResult(
                seasonItemId, null, seasonItemId, seasonItemId, seasonItemId, seasonItemId, null,
                null, null, null, null, null, null, null,
                importDate, false, importDate,
                seriesSeasonName, null, null, null, null, null,
                null, null, 0, null, Guid.Empty,
                seriesName, season, seriesSeasonName, seasonDescription, null, null, null,
                null, null
                );

            MockReader reader11 = MockDBUtils.AddReader(12,
                                                        "SELECT T0.MEDIA_ITEM_ID A3, T0.MEDIA_ITEM_ID A4, " +
                                                        "T0.SOURCE A0, T0.TYPE A1, T0.ID A2 " +
                                                        "FROM M_EXTERNALIDENTIFIER T0  " +
                                                        "WHERE T0.MEDIA_ITEM_ID = @V0",
                                                        CreateAttributeIdList(3, 4));

            reader11.AddResult(
                seasonItemId, seasonItemId,
                externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);

            MockDBUtils.AddReader(13,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, " +
                                  "T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 " +
                                  "FROM M_RELATIONSHIP T0  " +
                                  "WHERE T0.MEDIA_ITEM_ID = @V0",
                                  CreateAttributeIdList(3, 4));

            MockDBUtils.AddReader(14,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 FROM M_RELATIONSHIP T0  WHERE T0.LINKEDID IN (@V0)");

            MockDBUtils.AddReader(15,
                                  "SELECT T0.MEDIA_ITEM_ID A30, T0.MEDIA_ITEM_ID A31, T1.MEDIA_ITEM_ID A32, T2.MEDIA_ITEM_ID A33, T3.MEDIA_ITEM_ID A34, T4.MEDIA_ITEM_ID A35, T5.MEDIA_ITEM_ID A36, " +
                                  "T0.SERIESNAME_1 A0, T0.DESCRIPTION_0 A1, " +
                                  "T1.TITLE A2, T1.RECORDINGTIME A3, T1.RATING A4, T1.COMMENT A5, T1.PLAYCOUNT A6, T1.LASTPLAYED A7, " +
                                  "T2.SERIESNAME A8, T2.SEASON A9, T2.SERIESSEASONNAME A10, T2.EPISODENAME A11, T2.FIRSTAIRED A12, T2.TOTALRATING A13, T2.RATINGCOUNT A14, " +
                                  "T3.LASTIMPORTDATE A15, T3.DIRTY A16, T3.DATEADDED A17, " +
                                  "T4.SYSTEM_ID A18, T4.MIMETYPE A19, T4.SIZE A20, T4.PATH A21, T4.PARENTDIRECTORY A22, " +
                                  "T5.SERIESNAME_0 A23, T5.SEASON_0 A24, T5.SERIESSEASONNAME_0 A25, T5.DESCRIPTION A26, T5.FIRSTAIRED_0 A27, T5.TOTALRATING_0 A28, T5.RATINGCOUNT_0 A29 " +
                                  "FROM M_SERIESITEM T0 " +
                                  "INNER JOIN M_MEDIAITEM T1 ON T1.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_EPISODEITEM T2 ON T2.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_IMPORTEDITEM T3 ON T3.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_PROVIDERRESOURCE T4 ON T4.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_SEASONITEM T5 ON T5.MEDIA_ITEM_ID = T0.MEDIA_ITEM_ID  " +
                                  "WHERE T0.MEDIA_ITEM_ID IN(SELECT MEDIA_ITEM_ID FROM M_EXTERNALIDENTIFIER WHERE SOURCE = @V0 AND TYPE = @V1 AND ID = @V2)",
                                  CreateAttributeIdList(30, 36));

            MockDBUtils.AddReader(16, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");

            // Readers used by UpdateRelationships to find series item

            MockReader reader16 = MockDBUtils.AddReader(17,
                                                        "SELECT T6.MEDIA_ITEM_ID A30, T0.MEDIA_ITEM_ID A31, T1.MEDIA_ITEM_ID A32, T2.MEDIA_ITEM_ID A33, T3.MEDIA_ITEM_ID A34, T4.MEDIA_ITEM_ID A35, T5.MEDIA_ITEM_ID A36, " +
                                                        "T0.SERIESNAME A0, T0.SEASON A1, T0.SERIESSEASONNAME A2, T0.EPISODENAME A3, T0.FIRSTAIRED A4, T0.TOTALRATING A5, T0.RATINGCOUNT A6, " +
                                                        "T1.LASTIMPORTDATE A7, T1.DIRTY A8, T1.DATEADDED A9, " +
                                                        "T2.TITLE A10, T2.RECORDINGTIME A11, T2.RATING A12, T2.COMMENT A13, T2.PLAYCOUNT A14, T2.LASTPLAYED A15, " +
                                                        "T3.SYSTEM_ID A16, T3.MIMETYPE A17, T3.SIZE A18, T3.PATH A19, T3.PARENTDIRECTORY A20, " +
                                                        "T4.SERIESNAME_0 A21, T4.SEASON_0 A22, T4.SERIESSEASONNAME_0 A23, T4.DESCRIPTION A24, T4.FIRSTAIRED_0 A25, T4.TOTALRATING_0 A26, T4.RATINGCOUNT_0 A27, " +
                                                        "T5.SERIESNAME_1 A28, T5.DESCRIPTION_0 A29 " +
                                                        "FROM MEDIA_ITEMS T6 " +
                                                        "LEFT OUTER JOIN M_EPISODEITEM T0 ON T0.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_IMPORTEDITEM T1 ON T1.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_MEDIAITEM T2 ON T2.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_PROVIDERRESOURCE T3 ON T3.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_SEASONITEM T4 ON T4.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                                        "LEFT OUTER JOIN M_SERIESITEM T5 ON T5.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID  " +
                                                        "WHERE T6.MEDIA_ITEM_ID = @V0",
                                                        CreateAttributeIdList(30, 36));

            reader16.AddResult(
                seriesItemId, null, seasonItemId, seasonItemId, seasonItemId, null, seriesItemId,
                null, null, null, null, null, null, null,
                importDate, false, importDate,
                seriesName, null, null, null, null, null,
                null, null, 0, null, Guid.Empty,
                null, null, null, null, null, null, null,
                seriesName, seriesDescription
                );

            MockReader reader17 = MockDBUtils.AddReader(18,
                                                        "SELECT T0.MEDIA_ITEM_ID A3, T0.MEDIA_ITEM_ID A4, " +
                                                        "T0.SOURCE A0, T0.TYPE A1, T0.ID A2 " +
                                                        "FROM M_EXTERNALIDENTIFIER T0  " +
                                                        "WHERE T0.MEDIA_ITEM_ID = @V0",
                                                        CreateAttributeIdList(3, 4));

            reader17.AddResult(
                seriesItemId, seriesItemId,
                externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);

            MockDBUtils.AddReader(19,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, " +
                                  "T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 " +
                                  "FROM M_RELATIONSHIP T0  " +
                                  "WHERE T0.MEDIA_ITEM_ID = @V0",
                                  CreateAttributeIdList(4, 5));

            MockDBUtils.AddReader(20,
                                  "SELECT T0.MEDIA_ITEM_ID A4, T0.MEDIA_ITEM_ID A5, T0.ROLE A0, T0.LINKEDROLE A1, T0.LINKEDID A2, T0.RELATIONSHIPINDEX A3 FROM M_RELATIONSHIP T0  WHERE T0.LINKEDID IN (@V0)");

            MockReader reader20 = MockDBUtils.AddReader(21,
                                                        "SELECT MEDIA_ITEM_ID " +
                                                        "FROM M_EXTERNALIDENTIFIER " +
                                                        "WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND SOURCE = @SOURCE AND TYPE = @TYPE",
                                                        "MEDIA_ITEM_ID");

            reader20.AddResult(
                seasonItemId,
                externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);

            MockDBUtils.AddReader(22,
                                  "SELECT MEDIA_ITEM_ID " +
                                  "FROM M_RELATIONSHIP " +
                                  "WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ROLE = @ROLE AND LINKEDROLE = @LINKEDROLE AND LINKEDID = @LINKEDID",
                                  "MEDIA_ITEM_ID");

            MockReader reader22 = MockDBUtils.AddReader(23,
                                                        "SELECT MEDIA_ITEM_ID " +
                                                        "FROM M_EXTERNALIDENTIFIER " +
                                                        "WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND SOURCE = @SOURCE AND TYPE = @TYPE",
                                                        "MEDIA_ITEM_ID");

            reader22.AddResult(
                seasonItemId,
                externalSource, ExternalIdentifierAspect.TYPE_SERIES, externalSeriesId);

            MockDBUtils.AddReader(24,
                                  "SELECT MEDIA_ITEM_ID " +
                                  "FROM M_RELATIONSHIP " +
                                  "WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ROLE = @ROLE AND LINKEDROLE = @LINKEDROLE AND LINKEDID = @LINKEDID",
                                  "MEDIA_ITEM_ID");

            MockCore.Library.AddOrUpdateMediaItem(parentDirectoryId, systemId, path, episodeAspects.Values.SelectMany(x => x), true);

            MockCore.ShutdownLibrary();
        }
Example #14
0
        public void TestAddMediaItem()
        {
            MockDBUtils.Reset();
            MockCore.SetupLibrary();

            SingleTestMIA   mia1 = TestCommonUtils.CreateSingleMIA("SINGLE1", Cardinality.Inline, true, true);
            MultipleTestMIA mia2 = TestCommonUtils.CreateMultipleMIA("MULTIPLE2", Cardinality.Inline, true, false);
            MultipleTestMIA mia3 = TestCommonUtils.CreateMultipleMIA("MULTIPLE3", Cardinality.Inline, false, true);

            MockCore.Management.AddMediaItemAspectStorage(mia1.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(mia2.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(mia3.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ProviderResourceAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ImporterAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(MediaAspect.Metadata);

            IList <MediaItemAspect> aspects = new List <MediaItemAspect>();

            SingleMediaItemAspect aspect1 = new SingleMediaItemAspect(mia1.Metadata);

            aspect1.SetAttribute(mia1.ATTR_INTEGER, 1);
            aspect1.SetAttribute(mia1.ATTR_STRING, "one");
            aspects.Add(aspect1);

            MultipleMediaItemAspect aspect2_1 = new MultipleMediaItemAspect(mia2.Metadata);

            aspect2_1.SetAttribute(mia2.ATTR_STRING, "two.one");
            aspects.Add(aspect2_1);
            MultipleMediaItemAspect aspect2_2 = new MultipleMediaItemAspect(mia2.Metadata);

            aspect2_2.SetAttribute(mia2.ATTR_STRING, "two.two");
            aspects.Add(aspect2_2);

            MultipleMediaItemAspect aspect3_1 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_1.SetAttribute(mia3.ATTR_INTEGER, 31);
            aspects.Add(aspect3_1);
            MultipleMediaItemAspect aspect3_2 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_2.SetAttribute(mia3.ATTR_INTEGER, 32);
            aspects.Add(aspect3_2);
            MultipleMediaItemAspect aspect3_3 = new MultipleMediaItemAspect(mia3.Metadata);

            aspect3_3.SetAttribute(mia3.ATTR_INTEGER, 33);
            aspects.Add(aspect3_3);

            MockDBUtils.AddReader(1, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");
            MockDBUtils.AddReader(2, "SELECT T6.MEDIA_ITEM_ID A24, T0.MEDIA_ITEM_ID A25, T1.MEDIA_ITEM_ID A26, T2.MEDIA_ITEM_ID A27, T3.MEDIA_ITEM_ID A28, " +
                                  "T4.MEDIA_ITEM_ID A29, T5.MEDIA_ITEM_ID A30, T0.ATTR_STRING A0, T0.ATTR_INTEGER A1, T1.ATTR_ID A2, T1.ATTR_STRING A3, T2.ATTR_ID A4, T2.ATTR_INTEGER A5, " +
                                  "T3.SYSTEM_ID A6, T3.RESOURCEINDEX A7, T3.ISPRIMARY A8, T3.MIMETYPE A9, T3.SIZE A10, T3.PATH A11, T3.PARENTDIRECTORY A12, T4.LASTIMPORTDATE A13, T4.DIRTY A14, " +
                                  "T4.DATEADDED A15, T5.TITLE A16, T5.SORTTITLE A17, T5.RECORDINGTIME A18, T5.RATING A19, T5.COMMENT A20, T5.PLAYCOUNT A21, T5.LASTPLAYED A22, T5.ISVIRTUAL A23 " +
                                  "FROM MEDIA_ITEMS T6 LEFT OUTER JOIN M_SINGLE1 T0 ON T0.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID LEFT OUTER JOIN M_MULTIPLE2 T1 ON T1.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_MULTIPLE3 T2 ON T2.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID LEFT OUTER JOIN M_PROVIDERRESOURCE T3 ON T3.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_IMPORTEDITEM T4 ON T4.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID LEFT OUTER JOIN M_MEDIAITEM T5 ON T5.MEDIA_ITEM_ID = T6.MEDIA_ITEM_ID  WHERE T6.MEDIA_ITEM_ID = @V0", "V0");

            string       pathStr = "c:\\item.mp3";
            ResourcePath path    = LocalFsResourceProviderBase.ToResourcePath(pathStr);

            MockCore.Library.AddOrUpdateMediaItem(Guid.Empty, null, path, aspects, false);

            MockCore.ShutdownLibrary();
        }
        public PlaylistItem(VideoViewModel videoInfo, string resolvedPlaybackUrl)
            : base(Guid.Empty, new Dictionary <Guid, IList <MediaItemAspect> >
        {
            { ProviderResourceAspect.ASPECT_ID, new MediaItemAspect[] { new MultipleMediaItemAspect(ProviderResourceAspect.Metadata) } },
            { MediaAspect.ASPECT_ID, new MediaItemAspect[] { new SingleMediaItemAspect(MediaAspect.Metadata) } },
            { VideoAspect.ASPECT_ID, new MediaItemAspect[] { new SingleMediaItemAspect(VideoAspect.Metadata) } },
            { OnlineVideosAspect.ASPECT_ID, new MediaItemAspect[] { new SingleMediaItemAspect(OnlineVideosAspect.Metadata) } },
        })
        {
            SiteName  = videoInfo.SiteName;
            VideoInfo = videoInfo.VideoInfo;

            Aspects[OnlineVideosAspect.ASPECT_ID].First().SetAttribute(OnlineVideosAspect.ATTR_SITEUTIL, SiteName);

            ISystemResolver systemResolver = ServiceRegistration.Get <ISystemResolver>();

            IList <MultipleMediaItemAspect> providerResourceAspects;

            MediaItemAspect.TryGetAspects(Aspects, ProviderResourceAspect.Metadata, out providerResourceAspects);
            MultipleMediaItemAspect providerResourceAspect = providerResourceAspects.First();

            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_PRIMARY, true);
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemResolver.LocalSystemId);

            if (videoInfo.SiteUtilName == "DownloadedVideo")
            {
                providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, LocalFsResourceProviderBase.ToResourcePath(resolvedPlaybackUrl).Serialize());
                providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_MIME_TYPE, "video/unknown");
            }
            else
            {
                Uri uri;
                // Test if the resolved "url" is a real Uri (Sites can provide any content here)
                var isUriSource = Uri.TryCreate(resolvedPlaybackUrl, UriKind.Absolute, out uri);

                var value = isUriSource
                    ? RawUrlResourceProvider.ToProviderResourcePath(resolvedPlaybackUrl).Serialize()
                    : RawTokenResourceProvider.ToProviderResourcePath(resolvedPlaybackUrl).Serialize();
                providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, value);
                Aspects[OnlineVideosAspect.ASPECT_ID].First().SetAttribute(OnlineVideosAspect.ATTR_LONGURL, value);

                var isBrowser = videoInfo.SiteSettings.Player == PlayerType.Browser;
                providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_MIME_TYPE,
                                                    isBrowser
                        ? WebBrowserVideoPlayer.ONLINEVIDEOSBROWSER_MIMETYPE
                        : OnlineVideosPlayer.ONLINEVIDEOS_MIMETYPE);
            }

            MediaItemAspect.SetAttribute(Aspects, MediaAspect.ATTR_TITLE, videoInfo.Title);

            // TODO: Restore line after story plot was moved back to VideoAspect!
            // MediaItemAspect.SetAttribute(aspects, VideoAspect.ATTR_STORYPLOT, videoInfo.Description);

            DateTime parsedAirDate;

            if (DateTime.TryParse(videoInfo.VideoInfo.Airdate, out parsedAirDate))
            {
                MediaItemAspect.SetAttribute(Aspects, MediaAspect.ATTR_RECORDINGTIME, parsedAirDate);
            }
        }
Example #16
0
        public PlaylistItem(VideoViewModel videoInfo, string resolvedPlaybackUrl)
            : base(Guid.Empty, new Dictionary <Guid, MediaItemAspect>()
        {
            { ProviderResourceAspect.ASPECT_ID, new MediaItemAspect(ProviderResourceAspect.Metadata) },
            { MediaAspect.ASPECT_ID, new MediaItemAspect(MediaAspect.Metadata) },
            { VideoAspect.ASPECT_ID, new MediaItemAspect(VideoAspect.Metadata) }
        })
        {
            SiteName = videoInfo.SiteName;

            Aspects[ProviderResourceAspect.ASPECT_ID].SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, ServiceRegistration.Get <ISystemResolver>().LocalSystemId);
            if (videoInfo.SiteUtilName == "DownloadedVideo")
            {
                Aspects[ProviderResourceAspect.ASPECT_ID].SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, LocalFsResourceProviderBase.ToResourcePath(resolvedPlaybackUrl).Serialize());
                Aspects[MediaAspect.ASPECT_ID].SetAttribute(MediaAspect.ATTR_MIME_TYPE, "video/unknown");
            }
            else
            {
                Aspects[ProviderResourceAspect.ASPECT_ID].SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, RawUrlResourceProvider.ToProviderResourcePath(resolvedPlaybackUrl).Serialize());
                Aspects[MediaAspect.ASPECT_ID].SetAttribute(MediaAspect.ATTR_MIME_TYPE, OnlineVideosPlayer.ONLINEVIDEOS_MIMETYPE);
            }

            Aspects[MediaAspect.ASPECT_ID].SetAttribute(MediaAspect.ATTR_TITLE, videoInfo.Title);

            Aspects[VideoAspect.ASPECT_ID].SetAttribute(VideoAspect.ATTR_STORYPLOT, videoInfo.Description);

            DateTime parsedAirDate;

            if (DateTime.TryParse(videoInfo.VideoInfo.Airdate, out parsedAirDate))
            {
                Aspects[MediaAspect.ASPECT_ID].SetAttribute(MediaAspect.ATTR_RECORDINGTIME, parsedAirDate);
            }
        }
Example #17
0
        public void ChooseImportFile()
        {
            string importFile   = ImportFile;
            string initialPath  = string.IsNullOrEmpty(importFile) ? null : DosPathHelper.GetDirectory(importFile);
            Guid   dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Consts.RES_CHOOSE_IMPORT_FILE_DIALOG_HEADER, true, false,
                                                                                           string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                           path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }
                string extension = StringUtils.TrimToEmpty(DosPathHelper.GetExtension(choosenPath)).ToLowerInvariant();
                return((extension == ".m3u" || extension == ".m3u8") && File.Exists(choosenPath));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }
            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                ImportFile = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            },
                                                                   null);
        }
Example #18
0
        public void SearchIcon()
        {
            string initialPath  = "C:\\";
            Guid   dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(S_ICO, true, false,
                                                                                           string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                           path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(true);
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath => { IconPath = LocalFsResourceProviderBase.ToDosPath(choosenPath); }, null);
        }
Example #19
0
        public override void ExecuteConfiguration()
        {
            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            var pathEntry = Setting as PathEntry;

            if (pathEntry == null)
            {
                return;
            }

            Guid dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(Help.Evaluate(), pathEntry.PathType == PathEntry.PathSelectionType.File, false,
                                                                                         string.IsNullOrEmpty(pathEntry.Path) ? null : LocalFsResourceProviderBase.ToResourcePath(pathEntry.Path),
                                                                                         path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                return(!string.IsNullOrEmpty(choosenPath));
            });

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                pathEntry.Path = LocalFsResourceProviderBase.ToDosPath(choosenPath);
                Save();
                _pathBrowserCloseWatcher.Dispose();
                _pathBrowserCloseWatcher = null;
            },
                                                                   null);
        }
Example #20
0
        public void TestEditSmallMediaItem()
        {
            MockDBUtils.Reset();
            MockCore.SetupLibrary();

            MultipleTestMIA mia1 = TestCommonUtils.CreateMultipleMIA("MULTIPLE1", Cardinality.Inline, true, false);

            MockCore.Management.AddMediaItemAspectStorage(mia1.Metadata);

            MockCore.Management.AddMediaItemAspectStorage(ProviderResourceAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(ImporterAspect.Metadata);
            MockCore.Management.AddMediaItemAspectStorage(MediaAspect.Metadata);

            IList <MediaItemAspect> aspects = new List <MediaItemAspect>();

            MultipleMediaItemAspect aspect1_1 = new MultipleMediaItemAspect(mia1.Metadata);

            aspect1_1.SetAttribute(mia1.ATTR_STRING, "1_1");
            aspect1_1.SetAttribute(mia1.ATTR_STRING, "one.three");
            aspects.Add(aspect1_1);
            MultipleMediaItemAspect aspect1_2 = new MultipleMediaItemAspect(mia1.Metadata);

            aspect1_2.SetAttribute(mia1.ATTR_STRING, "1_2");
            aspect1_2.SetAttribute(mia1.ATTR_STRING, "one.two");
            aspects.Add(aspect1_2);

            Guid itemId = new Guid("aaaaaaaa-1111-1111-1111-aaaaaaaaaaaa");

            MockReader resourceReader = MockDBUtils.AddReader(1, "SELECT MEDIA_ITEM_ID FROM M_PROVIDERRESOURCE WHERE SYSTEM_ID = @SYSTEM_ID AND PATH = @PATH", "MEDIA_ITEM_ID");

            resourceReader.AddResult(itemId);

            DateTime importDate;

            DateTime.TryParse("2014-10-11 12:34:56", out importDate);
            MockReader importReader = MockDBUtils.AddReader(2, "SELECT LASTIMPORTDATE A0, DIRTY A1, DATEADDED A2 FROM M_IMPORTEDITEM WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "A0", "A1", "A2");

            importReader.AddResult(importDate, "false", importDate);

            string     pathStr   = @"c:\item.mp3";
            MockReader mraReader = MockDBUtils.AddReader(3, "SELECT SYSTEM_ID A0, RESOURCEINDEX A1, ISPRIMARY A2, MIMETYPE A3, SIZE A4, PATH A5, PARENTDIRECTORY A6 FROM M_PROVIDERRESOURCE WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID", "MEDIA_ITEM_ID");

            mraReader.AddResult(null, 0, true, "audio/mp3", 100, pathStr, Guid.Empty);

            MockReader mia1Reader1 = MockDBUtils.AddReader(4, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE1 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");

            mia1Reader1.AddResult(itemId, "1_1");

            MockReader mia1Reader2 = MockDBUtils.AddReader(5, "SELECT MEDIA_ITEM_ID FROM M_MULTIPLE1 WHERE MEDIA_ITEM_ID = @MEDIA_ITEM_ID AND ATTR_ID = @ATTR_ID", "MEDIA_ITEM_ID", "ATTR_ID");

            mia1Reader2.AddResult(itemId, "1_1");

            MockDBUtils.AddReader(6, "SELECT T4.MEDIA_ITEM_ID A20, T0.MEDIA_ITEM_ID A21, T1.MEDIA_ITEM_ID A22, T2.MEDIA_ITEM_ID A23, T3.MEDIA_ITEM_ID A24, T0.ATTR_ID A0, T0.ATTR_STRING A1, T1.SYSTEM_ID A2, " +
                                  "T1.RESOURCEINDEX A3, T1.ISPRIMARY A4, T1.MIMETYPE A5, T1.SIZE A6, T1.PATH A7, T1.PARENTDIRECTORY A8, T2.LASTIMPORTDATE A9, T2.DIRTY A10, T2.DATEADDED A11, T3.TITLE A12, T3.SORTTITLE A13, T3.RECORDINGTIME A14, " +
                                  "T3.RATING A15, T3.COMMENT A16, T3.PLAYCOUNT A17, T3.LASTPLAYED A18, T3.ISVIRTUAL A19 FROM MEDIA_ITEMS T4 LEFT OUTER JOIN M_MULTIPLE1 T0 ON T0.MEDIA_ITEM_ID = T4.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_PROVIDERRESOURCE T1 ON T1.MEDIA_ITEM_ID = T4.MEDIA_ITEM_ID LEFT OUTER JOIN M_IMPORTEDITEM T2 ON T2.MEDIA_ITEM_ID = T4.MEDIA_ITEM_ID " +
                                  "LEFT OUTER JOIN M_MEDIAITEM T3 ON T3.MEDIA_ITEM_ID = T4.MEDIA_ITEM_ID  WHERE T4.MEDIA_ITEM_ID = @V0", "V0");

            ResourcePath path = LocalFsResourceProviderBase.ToResourcePath(pathStr);

            MockCore.Library.AddOrUpdateMediaItem(Guid.Empty, null, path, aspects, true);

            MockCore.ShutdownLibrary();
        }
Example #21
0
        public void ChooseBackgroundVideo()
        {
            string videoFilename = BackgroundVideoFilename;
            string initialPath   = string.IsNullOrEmpty(videoFilename) ? null : DosPathHelper.GetDirectory(videoFilename);
            Guid   dialogHandle  = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(RES_HEADER_CHOOSE_VIDEO, true, false,
                                                                                            string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                            path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(MediaItemHelper.IsValidVideo(MediaItemHelper.CreateMediaItem(choosenPath)));
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                BackgroundVideoFilename = LocalFsResourceProviderBase.ToDosPath(choosenPath);
            },
                                                                   null);
        }
Example #22
0
        public void SearchApp()
        {
            string initialPath  = "C:\\";
            Guid   dialogHandle = ServiceRegistration.Get <IPathBrowser>().ShowPathBrowser(S_APP, true, false,
                                                                                           string.IsNullOrEmpty(initialPath) ? null : LocalFsResourceProviderBase.ToResourcePath(initialPath),
                                                                                           path =>
            {
                string choosenPath = LocalFsResourceProviderBase.ToDosPath(path.LastPathSegment.Path);
                if (string.IsNullOrEmpty(choosenPath))
                {
                    return(false);
                }

                return(true);
            });

            if (_pathBrowserCloseWatcher != null)
            {
                _pathBrowserCloseWatcher.Dispose();
            }

            _pathBrowserCloseWatcher = new PathBrowserCloseWatcher(this, dialogHandle, choosenPath =>
            {
                AppPath = LocalFsResourceProviderBase.ToDosPath(choosenPath);

                ShortName = choosenPath.FileName.Substring(0, choosenPath.FileName.LastIndexOf(".", System.StringComparison.Ordinal));

                var icon = Icon.ExtractAssociatedIcon(AppPath);

                if (icon != null)
                {
                    IconPath = Help.GetIconPfad(choosenPath.FileName, icon.ToBitmap());
                }
            }, null);
        }