| | 1 | | using System.Collections.Generic; |
| | 2 | | using System.Globalization; |
| | 3 | | using System.IO; |
| | 4 | | using System.Xml; |
| | 5 | | using MediaBrowser.Controller.Configuration; |
| | 6 | | using MediaBrowser.Controller.Entities; |
| | 7 | | using MediaBrowser.Controller.Entities.TV; |
| | 8 | | using MediaBrowser.Controller.Library; |
| | 9 | | using MediaBrowser.Model.IO; |
| | 10 | | using Microsoft.Extensions.Logging; |
| | 11 | |
|
| | 12 | | namespace MediaBrowser.XbmcMetadata.Savers |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Nfo saver for seasons. |
| | 16 | | /// </summary> |
| | 17 | | public class SeasonNfoSaver : BaseNfoSaver |
| | 18 | | { |
| | 19 | | /// <summary> |
| | 20 | | /// Initializes a new instance of the <see cref="SeasonNfoSaver"/> class. |
| | 21 | | /// </summary> |
| | 22 | | /// <param name="fileSystem">The file system.</param> |
| | 23 | | /// <param name="configurationManager">the server configuration manager.</param> |
| | 24 | | /// <param name="libraryManager">The library manager.</param> |
| | 25 | | /// <param name="userManager">The user manager.</param> |
| | 26 | | /// <param name="userDataManager">The user data manager.</param> |
| | 27 | | /// <param name="logger">The logger.</param> |
| | 28 | | public SeasonNfoSaver( |
| | 29 | | IFileSystem fileSystem, |
| | 30 | | IServerConfigurationManager configurationManager, |
| | 31 | | ILibraryManager libraryManager, |
| | 32 | | IUserManager userManager, |
| | 33 | | IUserDataManager userDataManager, |
| | 34 | | ILogger<SeasonNfoSaver> logger) |
| 21 | 35 | | : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger) |
| | 36 | | { |
| 21 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <inheritdoc /> |
| | 40 | | protected override string GetLocalSavePath(BaseItem item) |
| 0 | 41 | | => Path.Combine(item.Path, "season.nfo"); |
| | 42 | |
|
| | 43 | | /// <inheritdoc /> |
| | 44 | | protected override string GetRootElementName(BaseItem item) |
| 0 | 45 | | => "season"; |
| | 46 | |
|
| | 47 | | /// <inheritdoc /> |
| | 48 | | public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType) |
| | 49 | | { |
| 131 | 50 | | if (!item.SupportsLocalMetadata) |
| | 51 | | { |
| 0 | 52 | | return false; |
| | 53 | | } |
| | 54 | |
|
| 131 | 55 | | if (item is not Season) |
| | 56 | | { |
| 131 | 57 | | return false; |
| | 58 | | } |
| | 59 | |
|
| 0 | 60 | | return updateType >= MinimumUpdateType || (updateType >= ItemUpdateType.MetadataImport && File.Exists(GetSav |
| | 61 | | } |
| | 62 | |
|
| | 63 | | /// <inheritdoc /> |
| | 64 | | protected override void WriteCustomElements(BaseItem item, XmlWriter writer) |
| | 65 | | { |
| 0 | 66 | | var season = (Season)item; |
| | 67 | |
|
| 0 | 68 | | if (season.IndexNumber.HasValue) |
| | 69 | | { |
| 0 | 70 | | writer.WriteElementString("seasonnumber", season.IndexNumber.Value.ToString(CultureInfo.InvariantCulture |
| | 71 | | } |
| 0 | 72 | | } |
| | 73 | |
|
| | 74 | | /// <inheritdoc /> |
| | 75 | | protected override IEnumerable<string> GetTagsUsed(BaseItem item) |
| | 76 | | { |
| | 77 | | foreach (var tag in base.GetTagsUsed(item)) |
| | 78 | | { |
| | 79 | | yield return tag; |
| | 80 | | } |
| | 81 | |
|
| | 82 | | yield return "seasonnumber"; |
| | 83 | | } |
| | 84 | | } |
| | 85 | | } |