예제 #1
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on
            if (_config.Configuration.SaveLocalMeta && (wasMetadataEdited || wasMetadataDownloaded))
            {
                if (item is MusicArtist)
                {
                    return true;
                }
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if (wasMetadataDownloaded || wasMetadataEdited)
            {
                if (item is Artist)
                {
                    return true;
                }
            }

            return false;
        }
예제 #2
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on
            if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
            {
                if (item is MusicArtist)
                {
                    return true;
                }
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if (wasMetadataDownloaded || wasMetadataEdited)
            {
                var artist = item as MusicArtist;
                if (artist != null && artist.IsAccessedByName)
                {
                    return true;
                }
            }

            return false;
        }
예제 #3
0
파일: EntryPoint.cs 프로젝트: t-andre/Emby
        private async void SaveMetadataForItem(BaseItem item, ItemUpdateType updateReason)
        {
            var locationType = item.LocationType;
            if (locationType == LocationType.Remote ||
                locationType == LocationType.Virtual)
            {
                return;
            }

            if (!item.SupportsLocalMetadata)
            {
                return;
            }

            if (!item.IsSaveLocalMetadataEnabled())
            {
                return;
            }

            try
            {
                await _providerManager.SaveMetadata(item, updateReason, new[] { BaseNfoSaver.SaverName }).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving metadata for {0}", ex, item.Path ?? item.Name);
            }
        }
예제 #4
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            if (!(item is Folder))
            {
                return false;
            }

            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;
            
            // If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
            if ((_config.Configuration.SaveLocalMeta && wasMetadataDownloaded) || wasMetadataEdited)
            {
                if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
                    !(item is Season))
                {
                    return true;
                }
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if (wasMetadataDownloaded || wasMetadataEdited)
            {
                if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
                {
                    return true;
                }
            }

            return false;
        }
예제 #5
0
        private async void SaveMetadataForItem(BaseItem item, ItemUpdateType updateReason)
        {
            var userId = Plugin.Instance.Configuration.UserId;

            if (!userId.HasValue)
            {
                return;
            }

            var locationType = item.LocationType;
            if (locationType == LocationType.Remote ||
                locationType == LocationType.Virtual)
            {
                return;
            }

            try
            {
                await _providerManager.SaveMetadata(item, updateReason).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error saving metadata for {0}", ex, item.Path ?? item.Name);
            }
        }
예제 #6
0
        public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            return item is Episode && updateType >= MinimumUpdateType;
        }
예제 #7
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            return item is Playlist && updateType >= ItemUpdateType.MetadataImport;
        }
예제 #8
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            return item is MusicAlbum && updateType >= ItemUpdateType.MetadataDownload;
        }
예제 #9
0
        public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            return item is Series && updateType >= ItemUpdateType.ImageUpdate;
        }
예제 #10
0
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            // If new metadata has been downloaded or metadata was manually edited, proceed
            if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
                || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
            {
                return item is MusicArtist;
            }

            return false;
        }
예제 #11
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
            if ((_config.Configuration.SaveLocalMeta && (wasMetadataEdited || wasMetadataDownloaded)) || wasMetadataEdited)
            {
                return item is Series;
            }

            return false;
        }
예제 #12
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on
            if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
            {
                return item is GameSystem;
            }

            return false;
        }
예제 #13
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on
            if (_config.Configuration.SaveLocalMeta && (wasMetadataEdited || wasMetadataDownloaded))
            {
                return item is BoxSet;
            }

            return false;
        }
예제 #14
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if ((wasMetadataEdited || wasMetadataDownloaded))
            {
                return item is Person;
            }

            return false;
        }
예제 #15
0
        public override bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            if (!(item is Season))
            {
                return false;
            }

            return updateType >= ItemUpdateType.ImageUpdate || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSavePath(item)));
        }
 internal void UpdateItem(ItemUpdateType updateType)
 {
     switch (updateType)
     {
         case ItemUpdateType.Next:
             m_item.Next();
             break;
         case ItemUpdateType.Previous:
             m_item.Previous();
             break;
         case ItemUpdateType.Activate:
             m_item.Activate();
             break;
     }
     RefreshValueLabel();
 }
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            var locationType = item.LocationType;
            if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
            {
                return false;
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
                || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
            {
                return item is Season;
            }

            return false;
        }
예제 #18
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            var video = item as Video;

            // Check parent for null to avoid running this against things like video backdrops
            if (video != null && !(item is Episode) && !video.IsOwnedItem)
            {
                return updateType >= ItemUpdateType.MetadataDownload;
            }

            return false;
        }
예제 #19
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            if (!item.SupportsLocalMetadata)
            {
                return false;
            }

            if (item is Folder)
            {
                if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
                    !(item is Season) &&
                    !(item is GameSystem))
                {
                    return updateType >= ItemUpdateType.MetadataDownload;
                }
            }

            return false;
        }
예제 #20
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
            if ((_config.Configuration.SaveLocalMeta && (wasMetadataEdited || wasMetadataDownloaded)) || wasMetadataEdited)
            {
                var trailer = item as Trailer;

                // Don't support local trailers
                if (trailer != null)
                {
                    return !trailer.IsLocalTrailer;
                }

                return item is Movie || item is MusicVideo || item is AdultVideo;
            }

            return false;
        }
예제 #21
0
        /// <summary>
        /// Determines whether [is enabled for] [the specified item].
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="updateType">Type of the update.</param>
        /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            var wasMetadataEdited = (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit;
            var wasMetadataDownloaded = (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload;

            // If new metadata has been downloaded and save local is on
            if (item.IsSaveLocalMetadataEnabled() && (wasMetadataEdited || wasMetadataDownloaded))
            {
                var trailer = item as Trailer;

                // Don't support local trailers
                if (trailer != null)
                {
                    return !trailer.IsLocalTrailer;
                }

                // Check parent for null to avoid running this against things like video backdrops
                return item is Video && !(item is Episode) && item.Parent != null;
            }

            return false;
        }
예제 #22
0
 public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
 {
     return(item is Person);
 }
예제 #23
0
 /// <summary>
 /// Befores the save.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="isFullRefresh">if set to <c>true</c> [is full refresh].</param>
 /// <param name="currentUpdateType">Type of the current update.</param>
 /// <returns>ItemUpdateType.</returns>
 protected virtual Task <ItemUpdateType> BeforeSave(TItemType item, bool isFullRefresh, ItemUpdateType currentUpdateType)
 {
     return(_cachedResult);
 }
예제 #24
0
 protected Task SaveItem(TItemType item, ItemUpdateType reason, CancellationToken cancellationToken)
 {
     return(item.UpdateToRepository(reason, cancellationToken));
 }
예제 #25
0
        protected override async Task <ItemUpdateType> BeforeSave(MusicArtist item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false);

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (!item.IsLocked)
                {
                    var itemFilter = item.GetItemFilter();

                    var taggedItems = item.IsAccessedByName ?
                                      _libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && itemFilter(i)).ToList() :
                                      item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder).ToList();

                    if (!item.LockedFields.Contains(MetadataFields.Genres))
                    {
                        var currentList = item.Genres.ToList();

                        item.Genres = taggedItems.SelectMany(i => i.Genres)
                                      .DistinctNames()
                                      .ToList();

                        if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
                        {
                            updateType = updateType | ItemUpdateType.MetadataEdit;
                        }
                    }
                }
            }

            return(updateType);
        }
예제 #26
0
        protected override ItemUpdateType BeforeSave(MusicAlbum item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.BeforeSave(item, isFullRefresh, currentUpdateType);

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (!item.IsLocked)
                {
                    var songs = item.GetRecursiveChildren(i => i is Audio)
                                .Cast <Audio>()
                                .ToList();

                    if (!item.LockedFields.Contains(MetadataFields.Genres))
                    {
                        var currentList = item.Genres.ToList();

                        item.Genres = songs.SelectMany(i => i.Genres)
                                      .Distinct(StringComparer.OrdinalIgnoreCase)
                                      .ToList();

                        if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
                        {
                            updateType = updateType | ItemUpdateType.MetadataEdit;
                        }
                    }

                    if (!item.LockedFields.Contains(MetadataFields.Studios))
                    {
                        var currentList = item.Studios.ToList();

                        item.Studios = songs.SelectMany(i => i.Studios)
                                       .Distinct(StringComparer.OrdinalIgnoreCase)
                                       .ToList();

                        if (currentList.Count != item.Studios.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Studios.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
                        {
                            updateType = updateType | ItemUpdateType.MetadataEdit;
                        }
                    }

                    if (!item.LockedFields.Contains(MetadataFields.Name))
                    {
                        var name = songs.Select(i => i.Album).FirstOrDefault(i => !string.IsNullOrEmpty(i));

                        if (!string.IsNullOrEmpty(name))
                        {
                            if (!string.Equals(item.Name, name, StringComparison.Ordinal))
                            {
                                item.Name  = name;
                                updateType = updateType | ItemUpdateType.MetadataEdit;
                            }
                        }
                    }

                    updateType = updateType | SetAlbumArtistFromSongs(item, songs);
                    updateType = updateType | SetArtistsFromSongs(item, songs);
                    updateType = updateType | SetDateFromSongs(item, songs);
                }
            }

            return(updateType);
        }
예제 #27
0
        public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType)
        {
            var locationType = item.LocationType;
            if (locationType == LocationType.Remote || locationType == LocationType.Virtual)
            {
                return false;
            }

            // If new metadata has been downloaded or metadata was manually edited, proceed
            if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
                || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
            {
                var video = item as Video;

                // Check parent for null to avoid running this against things like video backdrops
                if (video != null && !(item is Episode) && !video.IsOwnedItem)
                {
                    return true;
                }
            }

            return false;
        }
예제 #28
0
        protected virtual ItemUpdateType UpdateMetadataFromChildren(TItemType item, IList <BaseItem> children, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = ItemUpdateType.None;

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                updateType |= UpdateCumulativeRunTimeTicks(item, children);
                updateType |= UpdateDateLastMediaAdded(item, children);

                if (EnableUpdatingPremiereDateFromChildren)
                {
                    updateType |= UpdatePremiereDate(item, children);
                }

                if (EnableUpdatingGenresFromChildren)
                {
                    updateType |= UpdateGenres(item, children);
                }

                if (EnableUpdatingStudiosFromChildren)
                {
                    updateType |= UpdateStudios(item, children);
                }

                if (EnableUpdatingOfficialRatingFromChildren)
                {
                    updateType |= UpdateOfficialRating(item, children);
                }
            }

            return(updateType);
        }
예제 #29
0
        protected override ItemUpdateType BeforeSaveInternal(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);

            var libraryFolderIds = item.GetLibraryFolderIds();

            var itemLibraryFolderIds = item.LibraryFolderIds;

            if (itemLibraryFolderIds == null || !libraryFolderIds.SequenceEqual(itemLibraryFolderIds))
            {
                item.LibraryFolderIds = libraryFolderIds;
                updateType           |= ItemUpdateType.MetadataImport;
            }

            return(updateType);
        }
예제 #30
0
        public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
        {
            // If new metadata has been downloaded or metadata was manually edited, proceed
            if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
                || (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
            {
                var trailer = item as Trailer;

                if (trailer != null)
                {
                    return !trailer.IsLocalTrailer;
                }

                return item is Movie || item is MusicVideo;
            }

            return false;
        }
예제 #31
0
        public static void DrawItemProperty(TSSItem item, string propertyName, string displayPropertyName = null, GUILayoutOption displayPropertyOption = null, bool shortCheckBox = false, bool alternative = false)
        {
            GUI.color           = Color.white;
            GUI.backgroundColor = Color.white;

            if (!ItemPropertyIsValid(propertyName))
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox(string.Format(invalidPropertyName.text, propertyName), MessageType.Warning);
                EditorGUILayout.EndHorizontal();
                return;
            }

            if (string.IsNullOrEmpty(displayPropertyName))
            {
                displayPropertyName = propertyName;
            }
            if (displayPropertyOption == null)
            {
                displayPropertyOption = TSSEditorUtils.max100pxWidth;
            }

            Type propertyType = GetItemPropertyType(propertyName);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(TSSText.GetHumanReadableString(displayPropertyName), displayPropertyOption);

            if (propertyType == typeof(float))
            {
                float displayedValue      = GetItemValue <float>(item, propertyName);
                bool  itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <float>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                float enteredValue = Mathf.Clamp(EditorGUILayout.FloatField(displayedValue), 0, float.MaxValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(bool))
            {
                bool displayedValue      = GetItemValue <bool>(item, propertyName);
                bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <bool>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                bool enteredValue = EditorGUILayout.Toggle(displayedValue, shortCheckBox ? TSSEditorUtils.max18pxWidth : TSSEditorUtils.max120pxWidth);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(string))
            {
                string displayedValue      = GetItemValue <string>(item, propertyName);
                bool   itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <string>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                string enteredValue = EditorGUILayout.TextField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(int))
            {
                int  displayedValue      = GetItemValue <int>(item, propertyName);
                bool itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <int>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                int enteredValue = EditorGUILayout.IntField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(ChainDirection))
            {
                ChainDirection displayedValue      = GetItemValue <ChainDirection>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ChainDirection>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ChainDirection enteredValue = (ChainDirection)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(RotationMode))
            {
                RotationMode displayedValue      = GetItemValue <RotationMode>(item, propertyName);
                bool         itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <RotationMode>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                RotationMode enteredValue = (RotationMode)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(MaterialMode))
            {
                MaterialMode displayedValue      = GetItemValue <MaterialMode>(item, propertyName);
                bool         itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <MaterialMode>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                MaterialMode enteredValue = (MaterialMode)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(AnimationCurve))
            {
                AnimationCurve displayedValue      = GetItemValue <AnimationCurve>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <AnimationCurve>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                AnimationCurve enteredValue = (AnimationCurve)EditorGUILayout.CurveField(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(TSSProfile))
            {
                TSSProfile displayedValue      = GetItemValue <TSSProfile>(item, propertyName);
                bool       itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <TSSProfile>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                TSSProfile enteredValue = (TSSProfile)EditorGUILayout.ObjectField(displayedValue, typeof(TSSProfile), false);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                    if (enteredValue != null && EditorUtility.DisplayDialog(confirmRevertTitle.text, string.Format(confirmRevertMessage.text, item.profile.name), "Yes", "No"))
                    {
                        TSSProfile.ProfileRevert(item, item.profile);
                    }
                }
            }
            else if (propertyType == typeof(ActivationMode))
            {
                if (alternative)
                {
                    ItemLoopModePattern displayedValue = ActivationModeToLoopPattern(GetItemValue <ActivationMode>(item, propertyName));
                    bool itemValuesIdentical           = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName));
                    if (!itemValuesIdentical)
                    {
                        EditorGUI.showMixedValue = true;
                    }
                    ItemLoopModePattern enteredValue = (ItemLoopModePattern)EditorGUILayout.EnumPopup(displayedValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        SelectedItemsSetValue(propertyName, LoopPatternToActivationMode(enteredValue));
                    }
                }
                else
                {
                    ActivationMode displayedValue      = GetItemValue <ActivationMode>(item, propertyName);
                    bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ActivationMode>(propertyName));
                    if (!itemValuesIdentical)
                    {
                        EditorGUI.showMixedValue = true;
                    }
                    ActivationMode enteredValue = (ActivationMode)EditorGUILayout.EnumPopup(displayedValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        SelectedItemsSetValue(propertyName, enteredValue);
                    }
                }
            }
            else if (propertyType == typeof(ButtonDirection))
            {
                ButtonDirection displayedValue      = GetItemValue <ButtonDirection>(item, propertyName);
                bool            itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ButtonDirection>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ButtonDirection enteredValue = (ButtonDirection)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(ItemUpdateType))
            {
                ItemUpdateType displayedValue      = GetItemValue <ItemUpdateType>(item, propertyName);
                bool           itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <ItemUpdateType>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                ItemUpdateType enteredValue = (ItemUpdateType)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }
            else if (propertyType == typeof(PathNormal))
            {
                PathNormal displayedValue      = GetItemValue <PathNormal>(item, propertyName);
                bool       itemValuesIdentical = ValuesIsIdentical(GetSelectedItemsValues <PathNormal>(propertyName));
                if (!itemValuesIdentical)
                {
                    EditorGUI.showMixedValue = true;
                }
                PathNormal enteredValue = (PathNormal)EditorGUILayout.EnumPopup(displayedValue);
                if (EditorGUI.EndChangeCheck())
                {
                    SelectedItemsSetValue(propertyName, enteredValue);
                }
            }


            EditorGUILayout.EndHorizontal();

            EditorGUI.showMixedValue = false;
        }
        protected override ItemUpdateType BeforeSave(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.BeforeSave(item, isFullRefresh, currentUpdateType);

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (!item.LockedFields.Contains(MetadataFields.OfficialRating))
                {
                    if (item.UpdateRatingToContent())
                    {
                        updateType = updateType | ItemUpdateType.MetadataEdit;
                    }
                }
            }

            return(updateType);
        }
예제 #33
0
 public static void UpdateToRepository(this BaseItem item, ItemUpdateType type)
 => item.UpdateToRepository(type, default);
예제 #34
0
 /// <summary>
 /// Determines whether [is enabled for] [the specified item].
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="updateType">Type of the update.</param>
 /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
 public abstract bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType);
예제 #35
0
        /// <inheritdoc />
        protected override ItemUpdateType BeforeSaveInternal(Episode item, bool isFullRefresh, ItemUpdateType updateType)
        {
            var updatedType = base.BeforeSaveInternal(item, isFullRefresh, updateType);

            var seriesName = item.FindSeriesName();

            if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
            {
                item.SeriesName = seriesName;
                updatedType    |= ItemUpdateType.MetadataImport;
            }

            var seasonName = item.FindSeasonName();

            if (!string.Equals(item.SeasonName, seasonName, StringComparison.Ordinal))
            {
                item.SeasonName = seasonName;
                updatedType    |= ItemUpdateType.MetadataImport;
            }

            var seriesId = item.FindSeriesId();

            if (!item.SeriesId.Equals(seriesId))
            {
                item.SeriesId = seriesId;
                updatedType  |= ItemUpdateType.MetadataImport;
            }

            var seasonId = item.FindSeasonId();

            if (!item.SeasonId.Equals(seasonId))
            {
                item.SeasonId = seasonId;
                updatedType  |= ItemUpdateType.MetadataImport;
            }

            var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();

            if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
            {
                item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
                updatedType |= ItemUpdateType.MetadataImport;
            }

            return(updatedType);
        }
예제 #36
0
파일: Video.cs 프로젝트: 7illusions/Emby
        public override async Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
        {
            await base.UpdateToRepository(updateReason, cancellationToken).ConfigureAwait(false);

            var localAlternates = GetLocalAlternateVersionIds()
                .Select(i => LibraryManager.GetItemById(i))
                .Where(i => i != null);

            foreach (var item in localAlternates)
            {
                item.ImageInfos = ImageInfos;
                item.Overview = Overview;
                item.ProductionYear = ProductionYear;
                item.PremiereDate = PremiereDate;
                item.CommunityRating = CommunityRating;
                item.OfficialRating = OfficialRating;
                item.Genres = Genres;
                item.ProviderIds = ProviderIds;

                await item.UpdateToRepository(ItemUpdateType.MetadataDownload, cancellationToken).ConfigureAwait(false);
            }
        }
예제 #37
0
        protected override ItemUpdateType BeforeSaveInternal(Season item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);

            if (item.IndexNumber.HasValue && item.IndexNumber.Value == 0)
            {
                if (!string.Equals(item.Name, ServerConfigurationManager.Configuration.SeasonZeroDisplayName, StringComparison.OrdinalIgnoreCase))
                {
                    item.Name  = ServerConfigurationManager.Configuration.SeasonZeroDisplayName;
                    updateType = updateType | ItemUpdateType.MetadataEdit;
                }
            }

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                var episodes = item.GetEpisodes();
                updateType |= SavePremiereDate(item, episodes);
                updateType |= SaveIsVirtualItem(item, episodes);
            }

            var seriesName = item.FindSeriesName();

            if (!string.Equals(item.SeriesName, seriesName, StringComparison.Ordinal))
            {
                item.SeriesName = seriesName;
                updateType     |= ItemUpdateType.MetadataImport;
            }

            var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();

            if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
            {
                item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
                updateType |= ItemUpdateType.MetadataImport;
            }

            var seriesId = item.FindSeriesId();

            if (item.SeriesId != seriesId)
            {
                item.SeriesId = seriesId;
                updateType   |= ItemUpdateType.MetadataImport;
            }

            return(updateType);
        }
예제 #38
0
        protected virtual bool EnableUpdateMetadataFromChildren(TItemType item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (EnableUpdatingPremiereDateFromChildren || EnableUpdatingGenresFromChildren || EnableUpdatingStudiosFromChildren || EnableUpdatingOfficialRatingFromChildren)
                {
                    return(true);
                }

                var folder = item as Folder;
                if (folder != null)
                {
                    return(folder.SupportsDateLastMediaAdded || folder.SupportsCumulativeRunTimeTicks);
                }
            }

            return(false);
        }
예제 #39
0
        public Task <ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
        {
            item.SetImagePath(ImageType.Primary, item.Path);

            // Examples: https://github.com/mono/taglib-sharp/blob/a5f6949a53d09ce63ee7495580d6802921a21f14/tests/fixtures/TagLib.Tests.Images/NullOrientationTest.cs
            if (_includextensions.Contains(Path.GetExtension(item.Path) ?? string.Empty, StringComparer.OrdinalIgnoreCase))
            {
                try
                {
                    using (var fileStream = _fileSystem.OpenRead(item.Path))
                    {
                        using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), fileStream, null)))
                        {
                            var image = file as TagLib.Image.File;

                            var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;

                            if (tag != null)
                            {
                                var structure = tag.Structure;

                                if (structure != null)
                                {
                                    var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;

                                    if (exif != null)
                                    {
                                        var exifStructure = exif.Structure;

                                        if (exifStructure != null)
                                        {
                                            var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;

                                            if (entry != null)
                                            {
                                                double val = entry.Value.Numerator;
                                                val          /= entry.Value.Denominator;
                                                item.Aperture = val;
                                            }

                                            entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;

                                            if (entry != null)
                                            {
                                                double val = entry.Value.Numerator;
                                                val /= entry.Value.Denominator;
                                                item.ShutterSpeed = val;
                                            }
                                        }
                                    }
                                }
                            }

                            if (image != null)
                            {
                                item.CameraMake  = image.ImageTag.Make;
                                item.CameraModel = image.ImageTag.Model;

                                item.Width  = image.Properties.PhotoWidth;
                                item.Height = image.Properties.PhotoHeight;

                                var rating = image.ImageTag.Rating;
                                if (rating.HasValue)
                                {
                                    item.CommunityRating = rating;
                                }
                                else
                                {
                                    item.CommunityRating = null;
                                }

                                item.Overview = image.ImageTag.Comment;

                                if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
                                {
                                    item.Name = image.ImageTag.Title;
                                }

                                var dateTaken = image.ImageTag.DateTime;
                                if (dateTaken.HasValue)
                                {
                                    item.DateCreated    = dateTaken.Value;
                                    item.PremiereDate   = dateTaken.Value;
                                    item.ProductionYear = dateTaken.Value.Year;
                                }

                                item.Genres   = image.ImageTag.Genres.ToList();
                                item.Tags     = image.ImageTag.Keywords;
                                item.Software = image.ImageTag.Software;

                                if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None)
                                {
                                    item.Orientation = null;
                                }
                                else
                                {
                                    MediaBrowser.Model.Drawing.ImageOrientation orientation;
                                    if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation))
                                    {
                                        item.Orientation = orientation;
                                    }
                                }

                                item.ExposureTime = image.ImageTag.ExposureTime;
                                item.FocalLength  = image.ImageTag.FocalLength;

                                item.Latitude  = image.ImageTag.Latitude;
                                item.Longitude = image.ImageTag.Longitude;
                                item.Altitude  = image.ImageTag.Altitude;

                                if (image.ImageTag.ISOSpeedRatings.HasValue)
                                {
                                    item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value);
                                }
                                else
                                {
                                    item.IsoSpeedRating = null;
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Image Provider - Error reading image tag for {0}", e, item.Path);
                }
            }

            if (!item.Width.HasValue || !item.Height.HasValue)
            {
                var img  = item.GetImageInfo(ImageType.Primary, 0);
                var size = _imageProcessor.GetImageSize(item, img, false, false);

                if (size.Width > 0 && size.Height > 0)
                {
                    item.Width  = Convert.ToInt32(size.Width);
                    item.Height = Convert.ToInt32(size.Height);
                }
            }

            const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;

            return(Task.FromResult(result));
        }
예제 #40
0
        protected virtual ItemUpdateType BeforeSaveInternal(TItemType item, bool isFullRefresh, ItemUpdateType updateType)
        {
            if (EnableUpdateMetadataFromChildren(item, isFullRefresh, updateType))
            {
                if (isFullRefresh || updateType > ItemUpdateType.None)
                {
                    var children = GetChildrenForMetadataUpdates(item);

                    updateType = UpdateMetadataFromChildren(item, children, isFullRefresh, updateType);
                }
            }

            var presentationUniqueKey = item.CreatePresentationUniqueKey();

            if (!string.Equals(item.PresentationUniqueKey, presentationUniqueKey, StringComparison.Ordinal))
            {
                item.PresentationUniqueKey = presentationUniqueKey;
                updateType |= ItemUpdateType.MetadataImport;
            }

            return(updateType);
        }
예제 #41
0
 /// <summary>
 /// Saves the metadata.
 /// </summary>
 public void SaveMetadata(BaseItem item, ItemUpdateType updateType)
 {
     SaveMetadata(item, updateType, _savers);
 }
예제 #42
0
 public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
 {
     return(UserManager.UpdateUser(this));
 }
예제 #43
0
        protected async Task SaveItemAsync(MetadataResult <TItemType> result, LibraryOptions libraryOptions, ItemUpdateType reason, CancellationToken cancellationToken)
        {
            if (result.Item.SupportsPeople && result.People != null)
            {
                var baseItem = result.Item;

                LibraryManager.UpdatePeople(baseItem, result.People);
                await SavePeopleMetadataAsync(result.People, cancellationToken).ConfigureAwait(false);
            }

            await result.Item.UpdateToRepositoryAsync(reason, cancellationToken).ConfigureAwait(false);
        }
예제 #44
0
        /// <inheritdoc />
        protected override ItemUpdateType UpdateMetadataFromChildren(MusicAlbum item, IList <BaseItem> children, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.UpdateMetadataFromChildren(item, children, isFullRefresh, currentUpdateType);

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (!item.LockedFields.Contains(MetadataField.Name))
                {
                    var name = children.Select(i => i.Album).FirstOrDefault(i => !string.IsNullOrEmpty(i));

                    if (!string.IsNullOrEmpty(name) &&
                        !string.Equals(item.Name, name, StringComparison.Ordinal))
                    {
                        item.Name   = name;
                        updateType |= ItemUpdateType.MetadataEdit;
                    }
                }

                var songs = children.Cast <Audio>().ToArray();

                updateType |= SetAlbumArtistFromSongs(item, songs);
                updateType |= SetArtistsFromSongs(item, songs);
            }

            return(updateType);
        }
예제 #45
0
 public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
 {
     return(item is BoxSet && updateType >= MinimumUpdateType);
 }
예제 #46
0
 /// <summary>
 /// Determines whether [is enabled for] [the specified item].
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="updateType">Type of the update.</param>
 /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
 public abstract bool IsEnabledFor(BaseItem item, ItemUpdateType updateType);
예제 #47
0
 /// <summary>
 /// Saves the metadata.
 /// </summary>
 public void SaveMetadata(IHasMetadata item, ItemUpdateType updateType)
 {
     SaveMetadata(item, updateType, _savers);
 }
예제 #48
0
 /// <inheritdoc/>
 public void SaveMetadata(BaseItem item, ItemUpdateType updateType, IEnumerable <string> savers)
 {
     SaveMetadata(item, updateType, _savers.Where(i => savers.Contains(i.Name, StringComparer.OrdinalIgnoreCase)));
 }
예제 #49
0
 public override void UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
 {
     UserManager.UpdateUser(this);
 }
예제 #50
0
        /// <summary>
        /// Determines whether [is saver enabled for item] [the specified saver].
        /// </summary>
        private bool IsSaverEnabledForItem(IMetadataSaver saver, BaseItem item, LibraryOptions libraryOptions, ItemUpdateType updateType, bool includeDisabled)
        {
            var options = GetMetadataOptions(item);

            try
            {
                if (!saver.IsEnabledFor(item, updateType))
                {
                    return(false);
                }

                if (!includeDisabled)
                {
                    if (libraryOptions.MetadataSavers == null)
                    {
                        if (options.DisabledMetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
                        {
                            return(false);
                        }

                        if (!item.IsSaveLocalMetadataEnabled())
                        {
                            if (updateType >= ItemUpdateType.MetadataEdit)
                            {
                                // Manual edit occurred
                                // Even if save local is off, save locally anyway if the metadata file already exists
                                if (!(saver is IMetadataFileSaver fileSaver) || !File.Exists(fileSaver.GetSavePath(item)))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                // Manual edit did not occur
                                // Since local metadata saving is disabled, consider it disabled
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (!libraryOptions.MetadataSavers.Contains(saver.Name, StringComparer.OrdinalIgnoreCase))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error in {0}.IsEnabledFor", saver.Name);
                return(false);
            }
        }
예제 #51
0
 public ItemUpdatedEventArgs(ItemUpdateType type, IListItemEx newItem, IListItemEx previousItem, Int32 index) {
   this.UpdateType = type;
   this.NewItem = newItem;
   this.PreviousItem = previousItem;
   this.NewItemIndex = index;
 }
예제 #52
0
 /// <inheritdoc />
 public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
 => item.SupportsLocalMetadata && item is MusicArtist && updateType >= MinimumUpdateType;
예제 #53
0
 public void RaiseItemUpdated(ItemUpdateType type, IListItemEx old, IListItemEx newItem, Int32 index) {
   this.ItemUpdated?.Invoke(this, new ItemUpdatedEventArgs(type, newItem, old, index));
 }
예제 #54
0
        protected override ItemUpdateType BeforeSaveInternal(MusicArtist item, bool isFullRefresh, ItemUpdateType currentUpdateType)
        {
            var updateType = base.BeforeSaveInternal(item, isFullRefresh, currentUpdateType);

            if (isFullRefresh || currentUpdateType > ItemUpdateType.None)
            {
                if (!item.IsLocked && !item.LockedFields.Contains(MetadataFields.Genres))
                {
                    var taggedItems = item.IsAccessedByName ?
                                      item.GetTaggedItems(new Controller.Entities.InternalItemsQuery()
                    {
                        Recursive = true,
                        IsFolder  = false
                    }) :
                                      item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder);

                    var currentList = item.Genres;

                    item.Genres = taggedItems.SelectMany(i => i.Genres)
                                  .DistinctNames()
                                  .ToList();

                    if (currentList.Count != item.Genres.Count || !currentList.OrderBy(i => i).SequenceEqual(item.Genres.OrderBy(i => i), StringComparer.OrdinalIgnoreCase))
                    {
                        updateType = updateType | ItemUpdateType.MetadataEdit;
                    }
                }
            }

            return(updateType);
        }
예제 #55
0
 /// <summary>
 /// Saves the metadata.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="updateType">Type of the update.</param>
 /// <returns>Task.</returns>
 public Task SaveMetadata(IHasMetadata item, ItemUpdateType updateType)
 {
     return(SaveMetadata(item, updateType, _savers));
 }
예제 #56
0
 public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
 {
     DateLastSaved = DateTime.UtcNow;
     
     // Avoid library manager and keep out of in-memory cache
     // Not great that this class has to know about that, but we'll improve that later.
     return ItemRepository.SaveItem(this, cancellationToken);
 }
예제 #57
0
파일: User.cs 프로젝트: Cyrre/Emby
 public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
 {
     return UserManager.UpdateUser(this);
 }
예제 #58
0
 /// <summary>
 /// Saves the metadata.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="updateType">Type of the update.</param>
 /// <param name="savers">The savers.</param>
 /// <returns>Task.</returns>
 public Task SaveMetadata(IHasMetadata item, ItemUpdateType updateType, IEnumerable <string> savers)
 {
     return(SaveMetadata(item, updateType, _savers.Where(i => savers.Contains(i.Name, StringComparer.OrdinalIgnoreCase))));
 }