fixes #289 - Rename "Season 0" to "Specials"?
This commit is contained in:
parent
6be50fefc1
commit
1141fcc374
|
@ -45,6 +45,12 @@ namespace MediaBrowser.Model.Configuration
|
||||||
/// <value>The item by name path.</value>
|
/// <value>The item by name path.</value>
|
||||||
public string ItemsByNamePath { get; set; }
|
public string ItemsByNamePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the display name of the season zero.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The display name of the season zero.</value>
|
||||||
|
public string SeasonZeroDisplayName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the weather unit to use when displaying weather
|
/// Gets or sets the weather unit to use when displaying weather
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -260,6 +266,8 @@ namespace MediaBrowser.Model.Configuration
|
||||||
SortReplaceCharacters = new[] { ".", "+", "%" };
|
SortReplaceCharacters = new[] { ".", "+", "%" };
|
||||||
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
|
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
|
||||||
SortRemoveWords = new[] { "the", "a", "an" };
|
SortRemoveWords = new[] { "the", "a", "an" };
|
||||||
|
|
||||||
|
SeasonZeroDisplayName = "Specials";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using MediaBrowser.Common.ScheduledTasks;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
|
@ -159,6 +160,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// <param name="resolvers">The resolvers.</param>
|
/// <param name="resolvers">The resolvers.</param>
|
||||||
/// <param name="introProviders">The intro providers.</param>
|
/// <param name="introProviders">The intro providers.</param>
|
||||||
/// <param name="itemComparers">The item comparers.</param>
|
/// <param name="itemComparers">The item comparers.</param>
|
||||||
|
/// <param name="prescanTasks">The prescan tasks.</param>
|
||||||
public void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
public void AddParts(IEnumerable<IResolverIgnoreRule> rules,
|
||||||
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||||
IEnumerable<IItemResolver> resolvers,
|
IEnumerable<IItemResolver> resolvers,
|
||||||
|
@ -211,9 +213,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
private bool _internetProvidersEnabled;
|
private bool _internetProvidersEnabled;
|
||||||
private bool _peopleImageFetchingEnabled;
|
private bool _peopleImageFetchingEnabled;
|
||||||
private string _itemsByNamePath;
|
private string _itemsByNamePath;
|
||||||
|
private string _seasonZeroDisplayName;
|
||||||
|
|
||||||
private void RecordConfigurationValues(ServerConfiguration configuration)
|
private void RecordConfigurationValues(ServerConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
_seasonZeroDisplayName = ConfigurationManager.Configuration.SeasonZeroDisplayName;
|
||||||
_itemsByNamePath = ConfigurationManager.ApplicationPaths.ItemsByNamePath;
|
_itemsByNamePath = ConfigurationManager.ApplicationPaths.ItemsByNamePath;
|
||||||
_internetProvidersEnabled = configuration.EnableInternetProviders;
|
_internetProvidersEnabled = configuration.EnableInternetProviders;
|
||||||
_peopleImageFetchingEnabled = configuration.InternetProviderExcludeTypes == null || !configuration.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase);
|
_peopleImageFetchingEnabled = configuration.InternetProviderExcludeTypes == null || !configuration.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase);
|
||||||
|
@ -239,17 +243,25 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
refreshPeopleAfterUpdate = newConfigurationFetchesPeopleImages && !_peopleImageFetchingEnabled;
|
refreshPeopleAfterUpdate = newConfigurationFetchesPeopleImages && !_peopleImageFetchingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ibnPathChanged = !string.Equals(_itemsByNamePath, ConfigurationManager.ApplicationPaths.ItemsByNamePath);
|
var ibnPathChanged = !string.Equals(_itemsByNamePath, ConfigurationManager.ApplicationPaths.ItemsByNamePath, StringComparison.CurrentCulture);
|
||||||
|
|
||||||
if (ibnPathChanged)
|
if (ibnPathChanged)
|
||||||
{
|
{
|
||||||
_itemsByName.Clear();
|
_itemsByName.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var newSeasonZeroName = ConfigurationManager.Configuration.SeasonZeroDisplayName;
|
||||||
|
var seasonZeroNameChanged = !string.Equals(_seasonZeroDisplayName, newSeasonZeroName, StringComparison.CurrentCulture);
|
||||||
|
|
||||||
RecordConfigurationValues(config);
|
RecordConfigurationValues(config);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
if (seasonZeroNameChanged)
|
||||||
|
{
|
||||||
|
await UpdateSeasonZeroNames(newSeasonZeroName, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Any number of configuration settings could change the way the library is refreshed, so do that now
|
// Any number of configuration settings could change the way the library is refreshed, so do that now
|
||||||
_taskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>();
|
_taskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>();
|
||||||
|
|
||||||
|
@ -260,6 +272,27 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the season zero names.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newName">The new name.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
private Task UpdateSeasonZeroNames(string newName, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var seasons = RootFolder.RecursiveChildren
|
||||||
|
.OfType<Season>()
|
||||||
|
.Where(i => i.IndexNumber.HasValue && i.IndexNumber.Value == 0 && !string.Equals(i.Name, newName, StringComparison.CurrentCulture))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var season in seasons)
|
||||||
|
{
|
||||||
|
season.Name = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UpdateItems(seasons, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the library items cache.
|
/// Creates the library items cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1075,18 +1108,25 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the item.
|
/// Updates the items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="items">The items.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task UpdateItem(BaseItem item, CancellationToken cancellationToken)
|
private async Task UpdateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await ItemRepository.SaveItem(item, cancellationToken).ConfigureAwait(false);
|
var list = items.ToList();
|
||||||
|
|
||||||
|
await ItemRepository.SaveItems(list, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
UpdateItemInLibraryCache(item);
|
UpdateItemInLibraryCache(item);
|
||||||
|
}
|
||||||
|
|
||||||
if (ItemUpdated != null)
|
if (ItemUpdated != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1098,6 +1138,18 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the item.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
public Task UpdateItem(BaseItem item, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return UpdateItems(new[] { item }, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reports the item removed.
|
/// Reports the item removed.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -9,6 +10,20 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SeasonResolver : FolderResolver<Season>
|
public class SeasonResolver : FolderResolver<Season>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The _config
|
||||||
|
/// </summary>
|
||||||
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SeasonResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The config.</param>
|
||||||
|
public SeasonResolver(IServerConfigurationManager config)
|
||||||
|
{
|
||||||
|
_config = config;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves the specified args.
|
/// Resolves the specified args.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,10 +33,17 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
{
|
{
|
||||||
if (args.Parent is Series && args.IsDirectory)
|
if (args.Parent is Series && args.IsDirectory)
|
||||||
{
|
{
|
||||||
return new Season
|
var season = new Season
|
||||||
{
|
{
|
||||||
IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path)
|
IndexNumber = TVUtils.GetSeasonNumberFromPath(args.Path)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0)
|
||||||
|
{
|
||||||
|
season.Name = _config.Configuration.SeasonZeroDisplayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return season;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user