Merge pull request #2207 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-10-02 02:20:16 -04:00 committed by GitHub
commit 696cdf2737
17 changed files with 66 additions and 94 deletions

View File

@ -107,7 +107,7 @@ namespace MediaBrowser.Api.Playback
{ {
var authInfo = AuthorizationContext.GetAuthorizationInfo(Request); var authInfo = AuthorizationContext.GetAuthorizationInfo(Request);
var result = await _mediaSourceManager.OpenLiveStream(request, false, CancellationToken.None).ConfigureAwait(false); var result = await _mediaSourceManager.OpenLiveStream(request, true, CancellationToken.None).ConfigureAwait(false);
var profile = request.DeviceProfile; var profile = request.DeviceProfile;
if (profile == null) if (profile == null)

View File

@ -88,8 +88,6 @@ namespace MediaBrowser.Api
var result = new StartupConfiguration var result = new StartupConfiguration
{ {
UICulture = _config.Configuration.UICulture, UICulture = _config.Configuration.UICulture,
EnableInternetProviders = _config.Configuration.EnableInternetProviders,
SaveLocalMeta = _config.Configuration.SaveLocalMeta,
MetadataCountryCode = _config.Configuration.MetadataCountryCode, MetadataCountryCode = _config.Configuration.MetadataCountryCode,
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
}; };
@ -123,8 +121,6 @@ namespace MediaBrowser.Api
public void Post(UpdateStartupConfiguration request) public void Post(UpdateStartupConfiguration request)
{ {
_config.Configuration.UICulture = request.UICulture; _config.Configuration.UICulture = request.UICulture;
_config.Configuration.EnableInternetProviders = request.EnableInternetProviders;
_config.Configuration.SaveLocalMeta = request.SaveLocalMeta;
_config.Configuration.MetadataCountryCode = request.MetadataCountryCode; _config.Configuration.MetadataCountryCode = request.MetadataCountryCode;
_config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage;
_config.SaveConfiguration(); _config.SaveConfiguration();
@ -215,8 +211,6 @@ namespace MediaBrowser.Api
public class StartupConfiguration public class StartupConfiguration
{ {
public string UICulture { get; set; } public string UICulture { get; set; }
public bool EnableInternetProviders { get; set; }
public bool SaveLocalMeta { get; set; }
public string MetadataCountryCode { get; set; } public string MetadataCountryCode { get; set; }
public string PreferredMetadataLanguage { get; set; } public string PreferredMetadataLanguage { get; set; }
public string LiveTvTunerType { get; set; } public string LiveTvTunerType { get; set; }

View File

@ -422,7 +422,7 @@ namespace MediaBrowser.Controller.Entities
public virtual bool IsInternetMetadataEnabled() public virtual bool IsInternetMetadataEnabled()
{ {
return ConfigurationManager.Configuration.EnableInternetProviders; return LibraryManager.GetLibraryOptions(this).EnableInternetProviders;
} }
public virtual bool CanDelete() public virtual bool CanDelete()
@ -1341,7 +1341,9 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
return ConfigurationManager.Configuration.SaveLocalMeta; var libraryOptions = LibraryManager.GetLibraryOptions(this);
return libraryOptions.SaveLocalMetadata;
} }
/// <summary> /// <summary>

View File

@ -111,7 +111,7 @@ namespace MediaBrowser.Controller.Entities
{ {
LibraryOptions[path] = options; LibraryOptions[path] = options;
options.SchemaVersion = 2; options.SchemaVersion = 3;
XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path)); XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path));
} }
} }

View File

@ -2,18 +2,12 @@
{ {
public class ChapterOptions public class ChapterOptions
{ {
public bool EnableMovieChapterImageExtraction { get; set; }
public bool EnableEpisodeChapterImageExtraction { get; set; }
public bool EnableOtherVideoChapterImageExtraction { get; set; }
public bool DownloadMovieChapters { get; set; } public bool DownloadMovieChapters { get; set; }
public bool DownloadEpisodeChapters { get; set; } public bool DownloadEpisodeChapters { get; set; }
public string[] FetcherOrder { get; set; } public string[] FetcherOrder { get; set; }
public string[] DisabledFetchers { get; set; } public string[] DisabledFetchers { get; set; }
public bool ExtractDuringLibraryScan { get; set; }
public ChapterOptions() public ChapterOptions()
{ {
DownloadMovieChapters = true; DownloadMovieChapters = true;

View File

@ -11,11 +11,15 @@
public bool DownloadImagesInAdvance { get; set; } public bool DownloadImagesInAdvance { get; set; }
public MediaPathInfo[] PathInfos { get; set; } public MediaPathInfo[] PathInfos { get; set; }
public bool SaveLocalMetadata { get; set; }
public bool EnableInternetProviders { get; set; }
public LibraryOptions() public LibraryOptions()
{ {
EnablePhotos = true; EnablePhotos = true;
EnableRealtimeMonitor = true; EnableRealtimeMonitor = true;
PathInfos = new MediaPathInfo[] { }; PathInfos = new MediaPathInfo[] { };
EnableInternetProviders = true;
} }
} }

View File

@ -262,8 +262,8 @@ namespace MediaBrowser.Providers.MediaInfo
NormalizeChapterNames(chapters); NormalizeChapterNames(chapters);
var libraryOptions = _libraryManager.GetLibraryOptions(video); var libraryOptions = _libraryManager.GetLibraryOptions(video);
var extractDuringScan = chapterOptions.ExtractDuringLibraryScan; var extractDuringScan = false;
if (libraryOptions != null && libraryOptions.SchemaVersion >= 2) if (libraryOptions != null)
{ {
extractDuringScan = libraryOptions.ExtractChapterImagesDuringLibraryScan; extractDuringScan = libraryOptions.ExtractChapterImagesDuringLibraryScan;
} }

View File

@ -194,8 +194,8 @@ namespace MediaBrowser.Providers.Movies
{ {
var releases = movieData.releases.countries.Where(i => !string.IsNullOrWhiteSpace(i.certification)).ToList(); var releases = movieData.releases.countries.Where(i => !string.IsNullOrWhiteSpace(i.certification)).ToList();
var ourRelease = releases.FirstOrDefault(c => c.iso_3166_1.Equals(preferredCountryCode, StringComparison.OrdinalIgnoreCase)); var ourRelease = releases.FirstOrDefault(c => string.Equals(c.iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase));
var usRelease = releases.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)); var usRelease = releases.FirstOrDefault(c => string.Equals(c.iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
if (ourRelease != null) if (ourRelease != null)
{ {

View File

@ -118,7 +118,7 @@ namespace MediaBrowser.Providers.TV
var hasNewEpisodes = false; var hasNewEpisodes = false;
if (_config.Configuration.EnableInternetProviders && addNewItems) if (addNewItems && !group.Any(i => !i.IsInternetMetadataEnabled()))
{ {
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase)); var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));

View File

@ -74,12 +74,6 @@ namespace MediaBrowser.Providers.TV
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken) public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{ {
if (!_config.Configuration.EnableInternetProviders)
{
progress.Report(100);
return;
}
var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase)); var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase));
if (seriesConfig != null && seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase)) if (seriesConfig != null && seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase))
@ -116,7 +110,9 @@ namespace MediaBrowser.Providers.TV
IncludeItemTypes = new[] { typeof(Series).Name }, IncludeItemTypes = new[] { typeof(Series).Name },
Recursive = true, Recursive = true,
GroupByPresentationUniqueKey = false GroupByPresentationUniqueKey = false
}).Cast<Series>();
}).Cast<Series>()
.ToList();
var seriesIdsInLibrary = seriesList var seriesIdsInLibrary = seriesList
.Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb))) .Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
@ -126,6 +122,13 @@ namespace MediaBrowser.Providers.TV
var missingSeries = seriesIdsInLibrary.Except(existingDirectories, StringComparer.OrdinalIgnoreCase) var missingSeries = seriesIdsInLibrary.Except(existingDirectories, StringComparer.OrdinalIgnoreCase)
.ToList(); .ToList();
var enableInternetProviders = seriesList.Count == 0 ? false : seriesList[0].IsInternetMetadataEnabled();
if (!enableInternetProviders)
{
progress.Report(100);
return;
}
// If this is our first time, update all series // If this is our first time, update all series
if (string.IsNullOrEmpty(lastUpdateTime)) if (string.IsNullOrEmpty(lastUpdateTime))
{ {

View File

@ -93,12 +93,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
} }
} }
} }
if (responseHeaders == null)
if (responseHeaders != null)
{ {
AddResponseHeaders(result, responseHeaders); responseHeaders = new Dictionary<string, string>();
} }
responseHeaders["Expires"] = "-1";
AddResponseHeaders(result, responseHeaders);
return result; return result;
} }

View File

@ -1216,12 +1216,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (libraryFolder != null) if (libraryFolder != null)
{ {
info.ItemId = libraryFolder.Id.ToString("N"); info.ItemId = libraryFolder.Id.ToString("N");
} info.LibraryOptions = GetLibraryOptions(libraryFolder);
var collectionFolder = libraryFolder as CollectionFolder;
if (collectionFolder != null)
{
info.LibraryOptions = collectionFolder.GetLibraryOptions();
} }
return info; return info;
@ -1889,11 +1884,23 @@ namespace MediaBrowser.Server.Implementations.Library
public LibraryOptions GetLibraryOptions(BaseItem item) public LibraryOptions GetLibraryOptions(BaseItem item)
{ {
var collectionFolder = GetCollectionFolders(item) var collectionFolder = item as CollectionFolder;
if (collectionFolder == null)
{
collectionFolder = GetCollectionFolders(item)
.OfType<CollectionFolder>() .OfType<CollectionFolder>()
.FirstOrDefault(); .FirstOrDefault();
}
return collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions(); var options = collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions();
if (options.SchemaVersion < 3)
{
options.SaveLocalMetadata = ConfigurationManager.Configuration.SaveLocalMeta;
options.EnableInternetProviders = ConfigurationManager.Configuration.EnableInternetProviders;
}
return options;
} }
public string GetContentType(BaseItem item) public string GetContentType(BaseItem item)

View File

@ -456,7 +456,7 @@ namespace MediaBrowser.Server.Implementations.Library
} }
else else
{ {
_logger.Error("Failed to update MediaSource timestamp for {0}", id); _logger.Error("Failed to ping live stream {0}", id);
} }
} }
finally finally
@ -540,7 +540,7 @@ namespace MediaBrowser.Server.Implementations.Library
} }
private Timer _closeTimer; private Timer _closeTimer;
private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(60); private readonly TimeSpan _openStreamMaxAge = TimeSpan.FromSeconds(180);
private void StartCloseTimer() private void StartCloseTimer()
{ {

View File

@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
} }
var libraryOptions = _libraryManager.GetLibraryOptions(video); var libraryOptions = _libraryManager.GetLibraryOptions(video);
if (libraryOptions != null && libraryOptions.SchemaVersion >= 2) if (libraryOptions != null)
{ {
if (!libraryOptions.EnableChapterImageExtraction) if (!libraryOptions.EnableChapterImageExtraction)
{ {
@ -69,31 +69,9 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
} }
} }
else else
{
var options = _chapterManager.GetConfiguration();
if (video is Movie)
{
if (!options.EnableMovieChapterImageExtraction)
{ {
return false; return false;
} }
}
else if (video is Episode)
{
if (!options.EnableEpisodeChapterImageExtraction)
{
return false;
}
}
else
{
if (!options.EnableOtherVideoChapterImageExtraction)
{
return false;
}
}
}
// Can't extract images if there are no video streams // Can't extract images if there are no video streams
return video.DefaultVideoStreamIndex.HasValue; return video.DefaultVideoStreamIndex.HasValue;

View File

@ -41,12 +41,7 @@ namespace MediaBrowser.Server.Implementations.Session
/// <summary> /// <summary>
/// The _user data repository /// The _user data repository
/// </summary> /// </summary>
private readonly IUserDataManager _userDataRepository; private readonly IUserDataManager _userDataManager;
/// <summary>
/// The _user repository
/// </summary>
private readonly IUserRepository _userRepository;
/// <summary> /// <summary>
/// The _logger /// The _logger
@ -99,11 +94,10 @@ namespace MediaBrowser.Server.Implementations.Session
private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1); private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
public SessionManager(IUserDataManager userDataRepository, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager) public SessionManager(IUserDataManager userDataManager, ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager)
{ {
_userDataRepository = userDataRepository; _userDataManager = userDataManager;
_logger = logger; _logger = logger;
_userRepository = userRepository;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_userManager = userManager; _userManager = userManager;
_musicManager = musicManager; _musicManager = musicManager;
@ -248,13 +242,11 @@ namespace MediaBrowser.Server.Implementations.Session
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue; var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
user.LastActivityDate = activityDate; user.LastActivityDate = activityDate;
// Don't log in the db anymore frequently than 10 seconds if ((activityDate - userLastActivityDate).TotalSeconds > 60)
if ((activityDate - userLastActivityDate).TotalSeconds > 10)
{ {
try try
{ {
// Save this directly. No need to fire off all the events for this. await _userManager.UpdateUser(user).ConfigureAwait(false);
await _userRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -636,7 +628,7 @@ namespace MediaBrowser.Server.Implementations.Session
/// <returns>Task.</returns> /// <returns>Task.</returns>
private async Task OnPlaybackStart(Guid userId, IHasUserData item) private async Task OnPlaybackStart(Guid userId, IHasUserData item)
{ {
var data = _userDataRepository.GetUserData(userId, item); var data = _userDataManager.GetUserData(userId, item);
data.PlayCount++; data.PlayCount++;
data.LastPlayedDate = DateTime.UtcNow; data.LastPlayedDate = DateTime.UtcNow;
@ -646,7 +638,7 @@ namespace MediaBrowser.Server.Implementations.Session
data.Played = true; data.Played = true;
} }
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false); await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -713,17 +705,17 @@ namespace MediaBrowser.Server.Implementations.Session
private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info) private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info)
{ {
var data = _userDataRepository.GetUserData(user.Id, item); var data = _userDataManager.GetUserData(user.Id, item);
var positionTicks = info.PositionTicks; var positionTicks = info.PositionTicks;
if (positionTicks.HasValue) if (positionTicks.HasValue)
{ {
_userDataRepository.UpdatePlayState(item, data, positionTicks.Value); _userDataManager.UpdatePlayState(item, data, positionTicks.Value);
UpdatePlaybackSettings(user, info, data); UpdatePlaybackSettings(user, info, data);
await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false); await _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
} }
} }
@ -849,11 +841,11 @@ namespace MediaBrowser.Server.Implementations.Session
if (!playbackFailed) if (!playbackFailed)
{ {
var data = _userDataRepository.GetUserData(userId, item); var data = _userDataManager.GetUserData(userId, item);
if (positionTicks.HasValue) if (positionTicks.HasValue)
{ {
playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value); playedToCompletion = _userDataManager.UpdatePlayState(item, data, positionTicks.Value);
} }
else else
{ {
@ -864,7 +856,7 @@ namespace MediaBrowser.Server.Implementations.Session
playedToCompletion = true; playedToCompletion = true;
} }
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false); await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
} }
return playedToCompletion; return playedToCompletion;

View File

@ -435,7 +435,6 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance(UserDataManager); RegisterSingleInstance(UserDataManager);
UserRepository = await GetUserRepository().ConfigureAwait(false); UserRepository = await GetUserRepository().ConfigureAwait(false);
RegisterSingleInstance(UserRepository);
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, NativeApp.GetDbConnector()); var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LogManager, JsonSerializer, ApplicationPaths, NativeApp.GetDbConnector());
DisplayPreferencesRepository = displayPreferencesRepo; DisplayPreferencesRepository = displayPreferencesRepo;
@ -517,7 +516,7 @@ namespace MediaBrowser.Server.Startup.Common
MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager); MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager);
RegisterSingleInstance(MediaSourceManager); RegisterSingleInstance(MediaSourceManager);
SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager); SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
RegisterSingleInstance(SessionManager); RegisterSingleInstance(SessionManager);
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer, this); var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer, this);

View File

@ -67,9 +67,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Nat", "Mono.Nat\Mono.Nat.csproj", "{D7453B88-2266-4805-B39B-2B5A2A33E1BA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Nat", "Mono.Nat\Mono.Nat.csproj", "{D7453B88-2266-4805-B39B-2B5A2A33E1BA}"
EndProject EndProject
Global Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Mixed Platforms = Debug|Mixed Platforms