mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-19 16:46:36 +00:00
allow request header overrides
This commit is contained in:
@@ -759,7 +759,11 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
dto.AspectRatio = item.AspectRatio;
|
||||
|
||||
dto.BackdropImageTags = GetBackdropImageTags(item);
|
||||
dto.ScreenshotImageTags = GetScreenshotImageTags(item);
|
||||
|
||||
if (fields.Contains(ItemFields.ScreenshotImageTags))
|
||||
{
|
||||
dto.ScreenshotImageTags = GetScreenshotImageTags(item);
|
||||
}
|
||||
|
||||
if (fields.Contains(ItemFields.Genres))
|
||||
{
|
||||
|
||||
@@ -8,10 +8,10 @@ using MediaBrowser.Controller.Notifications;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Notifications;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -84,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
/// </summary>
|
||||
private void SetRangeValues()
|
||||
{
|
||||
var requestedRange = RequestedRanges.First();
|
||||
var requestedRange = RequestedRanges[0];
|
||||
|
||||
TotalContentLength = SourceStream.Length;
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
if (args.Parent != null)
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(Path.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(filename))
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1036,6 +1036,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
await i.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Pre-scan task cancelled: {0}", i.GetType().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running prescan task", ex);
|
||||
@@ -1077,6 +1081,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
await i.Run(innerProgress, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.Info("Post-scan task cancelled: {0}", i.GetType().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running postscan task", ex);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
@@ -37,6 +38,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
if (args.Parent.IsRoot) return null;
|
||||
if (args.Parent is MusicAlbum) return null;
|
||||
|
||||
// Optimization
|
||||
if (args.Parent is BoxSet || args.Parent is Series || args.Parent is Season)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
// If there's a collection type and it's not music, it can't be a series
|
||||
@@ -102,8 +109,10 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
// If list contains at least 2 audio files or at least one and no video files consider it to contain music
|
||||
var foundAudio = 0;
|
||||
|
||||
foreach (var fullName in list.Select(file => file.FullName))
|
||||
foreach (var file in list)
|
||||
{
|
||||
var fullName = file.FullName;
|
||||
|
||||
if (EntityResolutionHelper.IsAudioFile(fullName)) foundAudio++;
|
||||
if (foundAudio >= 2)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -41,6 +43,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
return null;
|
||||
}
|
||||
|
||||
// Optimization
|
||||
if (args.Parent is BoxSet || args.Parent is Series || args.Parent is Season)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
// If there's a collection type and it's not music, it can't be a series
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
var season = args.Parent as Season;
|
||||
|
||||
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
|
||||
if (season != null || args.Parent is Series)
|
||||
if (season != null)
|
||||
{
|
||||
Episode episode = null;
|
||||
|
||||
@@ -51,10 +51,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
|
||||
if (episode != null)
|
||||
{
|
||||
if (season != null)
|
||||
{
|
||||
episode.ParentIndexNumber = season.IndexNumber;
|
||||
}
|
||||
episode.ParentIndexNumber = season.IndexNumber;
|
||||
|
||||
if (episode.ParentIndexNumber == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
@@ -41,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
}
|
||||
|
||||
// Optimization to avoid running these tests against Seasons
|
||||
if (args.Parent is Series)
|
||||
if (args.Parent is Series || args.Parent is MusicArtist || args.Parent is MusicAlbum || args.Parent is BoxSet)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -23,12 +21,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// </summary>
|
||||
public class UserManager : IUserManager
|
||||
{
|
||||
/// <summary>
|
||||
/// The _active connections
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, SessionInfo> _activeConnections =
|
||||
new ConcurrentDictionary<string, SessionInfo>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// The _users
|
||||
/// </summary>
|
||||
@@ -64,24 +56,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all connections.
|
||||
/// </summary>
|
||||
/// <value>All connections.</value>
|
||||
public IEnumerable<SessionInfo> AllConnections
|
||||
{
|
||||
get { return _activeConnections.Values.OrderByDescending(c => c.LastActivityDate); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the active connections.
|
||||
/// </summary>
|
||||
/// <value>The active connections.</value>
|
||||
public IEnumerable<SessionInfo> RecentConnections
|
||||
{
|
||||
get { return AllConnections.Where(c => (DateTime.UtcNow - c.LastActivityDate).TotalMinutes <= 5); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
|
||||
@@ -57,10 +57,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToArray();
|
||||
|
||||
var allMusicArtists = allItems.OfType<MusicArtist>().ToList();
|
||||
var allSongs = allItems.OfType<Audio>().ToList();
|
||||
var allMusicArtists = allItems.OfType<MusicArtist>().ToArray();
|
||||
var allSongs = allItems.OfType<Audio>().ToArray();
|
||||
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
var numComplete = 0;
|
||||
|
||||
var userLibraries = _userManager.Users
|
||||
.Select(i => new Tuple<Guid, List<IHasArtist>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToList()))
|
||||
.ToList();
|
||||
.Select(i => new Tuple<Guid, IHasArtist[]>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToArray()))
|
||||
.ToArray();
|
||||
|
||||
foreach (var artist in allArtists)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= allArtists.Count;
|
||||
percent /= allArtists.Length;
|
||||
percent *= 20;
|
||||
|
||||
progress.Report(80 + percent);
|
||||
@@ -138,11 +138,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var items = allItems
|
||||
.Where(i => i.HasArtist(name))
|
||||
.ToList();
|
||||
.ToArray();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Count,
|
||||
TotalCount = items.Length,
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
private void MergeImages(Dictionary<ImageType, string> source, Dictionary<ImageType, string> target)
|
||||
{
|
||||
foreach (var key in source.Keys
|
||||
.ToList()
|
||||
.ToArray()
|
||||
.Where(k => !target.ContainsKey(k)))
|
||||
{
|
||||
string path;
|
||||
@@ -184,7 +184,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task{Artist[]}.</returns>
|
||||
private async Task<List<Artist>> GetAllArtists(IEnumerable<Audio> allSongs, CancellationToken cancellationToken, IProgress<double> progress)
|
||||
private async Task<Artist[]> GetAllArtists(IEnumerable<Audio> allSongs, CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
var allArtists = allSongs
|
||||
.SelectMany(i =>
|
||||
@@ -200,7 +200,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
return list;
|
||||
})
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
.ToArray();
|
||||
|
||||
const int maxTasks = 3;
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= allArtists.Count;
|
||||
percent /= allArtists.Length;
|
||||
|
||||
progress.Report(100 * percent);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
|
||||
return returnArtists.ToList();
|
||||
return returnArtists.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <param name="media">The media.</param>
|
||||
/// <param name="names">The names.</param>
|
||||
/// <param name="masterDictionary">The master dictionary.</param>
|
||||
internal static void SetItemCounts(Guid userId, BaseItem media, List<string> names, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
internal static void SetItemCounts(Guid userId, BaseItem media, IEnumerable<string> names, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var name in names)
|
||||
{
|
||||
|
||||
@@ -46,14 +46,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
private void RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||
|
||||
var userLibraries = _userManager.Users
|
||||
.Select(i => new Tuple<Guid, List<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i).ToList()))
|
||||
.Select(i => new Tuple<Guid, BaseItem[]>(i.Id, i.RootFolder.GetRecursiveChildren(i).ToArray()))
|
||||
.ToList();
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
@@ -122,7 +118,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
var names = media
|
||||
.People.Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
.ToArray();
|
||||
|
||||
CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Globalization;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
@@ -7,6 +6,7 @@ using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
@@ -92,13 +92,21 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var enableInternetProviders = ConfigurationManager.Configuration.EnableInternetProviders;
|
||||
var excludeTypes = ConfigurationManager.Configuration.InternetProviderExcludeTypes;
|
||||
|
||||
// Run the normal providers sequentially in order of priority
|
||||
foreach (var provider in MetadataProviders.Where(p => ProviderSupportsItem(p, item)))
|
||||
foreach (var provider in MetadataProviders)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (!ProviderSupportsItem(provider, item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip if internet providers are currently disabled
|
||||
if (provider.RequiresInternet && !ConfigurationManager.Configuration.EnableInternetProviders)
|
||||
if (provider.RequiresInternet && !enableInternetProviders)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -110,7 +118,10 @@ namespace MediaBrowser.Server.Implementations.Providers
|
||||
}
|
||||
|
||||
// Skip if internet provider and this type is not allowed
|
||||
if (provider.RequiresInternet && ConfigurationManager.Configuration.EnableInternetProviders && ConfigurationManager.Configuration.InternetProviderExcludeTypes.Contains(item.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
if (provider.RequiresInternet &&
|
||||
enableInternetProviders &&
|
||||
excludeTypes.Length > 0 &&
|
||||
excludeTypes.Contains(item.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Net.Sockets;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -10,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
|
||||
@@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Sorting
|
||||
{
|
||||
@@ -37,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return audio.Artists.FirstOrDefault() ?? string.Empty;
|
||||
return audio.Artists.Count == 0 ? null : audio.Artists[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
|
||||
@@ -8,7 +8,6 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Udp
|
||||
|
||||
Reference in New Issue
Block a user