Skip to content

Commit

Permalink
Merge pull request #3208 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored Mar 22, 2018
2 parents c7c89ae + e7ab8e1 commit 9800cc3
Show file tree
Hide file tree
Showing 102 changed files with 929 additions and 532 deletions.
14 changes: 14 additions & 0 deletions Emby.Server.Implementations/Library/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ public UserManager(ILogger logger, IServerConfigurationManager configurationMana
DeletePinFile();
}

public NameIdPair[] GetAuthenticationProviders()
{
return _authenticationProviders
.Where(i => i.IsEnabled)
.OrderBy(i => i is DefaultAuthenticationProvider ? 0 : 1)
.ThenBy(i => i.Name)
.Select(i => new NameIdPair
{
Name = i.Name,
Id = GetAuthenticationProviderId(i)
})
.ToArray();
}

public void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders)
{
_authenticationProviders = authenticationProviders.ToArray();
Expand Down
23 changes: 7 additions & 16 deletions Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Reflection;
using MediaBrowser.Model.Providers;
using Emby.Server.Implementations.LiveTv.TunerHosts;

namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
Expand Down Expand Up @@ -1430,8 +1431,6 @@ private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, Acti
var recordPath = GetRecordingPath(timer, remoteMetadata, out seriesPath);
var recordingStatus = RecordingStatus.New;

var recorder = GetRecorder();

string liveStreamId = null;

try
Expand All @@ -1445,6 +1444,8 @@ private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, Acti
var mediaStreamInfo = liveStreamInfo.Item2;
liveStreamId = mediaStreamInfo.Id;

var recorder = GetRecorder(liveStreamInfo.Item1, mediaStreamInfo);

recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath);
recordPath = EnsureFileUnique(recordPath, timer.Id);

Expand Down Expand Up @@ -1800,24 +1801,14 @@ private bool FileExists(string path, string timerId)
return false;
}

private IRecorder GetRecorder()
private IRecorder GetRecorder(ILiveStream liveStream, MediaSourceInfo mediaSource)
{
var config = GetConfiguration();

if (config.EnableRecordingEncoding)
if (mediaSource.RequiresLooping || !(mediaSource.Container ?? string.Empty).EndsWith("ts", StringComparison.OrdinalIgnoreCase))
{
return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory, _config, _assemblyInfo);
return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, _httpClient, _processFactory, _config, _assemblyInfo);
}

return new DirectRecorder(_logger, _httpClient, _fileSystem);

//var options = new LiveTvOptions
//{
// EnableOriginalAudioWithEncodedRecordings = true,
// RecordedVideoCodec = "copy",
// RecordingEncodingFormat = "ts"
//};
//return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, options, _httpClient, _processFactory, _config);
}

private void OnSuccessfulRecording(TimerInfo timer, string path)
Expand Down Expand Up @@ -2422,7 +2413,7 @@ private bool ShouldCancelTimerForSeriesTimer(SeriesTimerInfo seriesTimer, TimerI

if (!seriesTimer.RecordAnyTime)
{
if (Math.Abs(seriesTimer.StartDate.TimeOfDay.Ticks - timer.StartDate.TimeOfDay.Ticks) >= TimeSpan.FromMinutes(5).Ticks)
if (Math.Abs(seriesTimer.StartDate.TimeOfDay.Ticks - timer.StartDate.TimeOfDay.Ticks) >= TimeSpan.FromMinutes(10).Ticks)
{
return true;
}
Expand Down
66 changes: 14 additions & 52 deletions Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class EncodedRecorder : IRecorder
private readonly IHttpClient _httpClient;
private readonly IMediaEncoder _mediaEncoder;
private readonly IServerApplicationPaths _appPaths;
private readonly LiveTvOptions _liveTvOptions;
private bool _hasExited;
private Stream _logFileStream;
private string _targetPath;
Expand All @@ -44,39 +43,19 @@ public class EncodedRecorder : IRecorder
private readonly IServerConfigurationManager _config;
private readonly IAssemblyInfo _assemblyInfo;

public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory, IServerConfigurationManager config, IAssemblyInfo assemblyInfo)
public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, IHttpClient httpClient, IProcessFactory processFactory, IServerConfigurationManager config, IAssemblyInfo assemblyInfo)
{
_logger = logger;
_fileSystem = fileSystem;
_mediaEncoder = mediaEncoder;
_appPaths = appPaths;
_json = json;
_liveTvOptions = liveTvOptions;
_httpClient = httpClient;
_processFactory = processFactory;
_config = config;
_assemblyInfo = assemblyInfo;
}

private string OutputFormat
{
get
{
var format = _liveTvOptions.RecordingEncodingFormat;

if (string.Equals(format, "mkv", StringComparison.OrdinalIgnoreCase))
{
return "mkv";
}
if (string.Equals(format, "ts", StringComparison.OrdinalIgnoreCase))
{
return "ts";
}

return "mkv";
}
}

private bool CopySubtitles
{
get
Expand All @@ -88,12 +67,7 @@ private bool CopySubtitles

public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile)
{
var extension = OutputFormat;

if (string.Equals(extension, "mpegts", StringComparison.OrdinalIgnoreCase))
{
extension = "ts";
}
var extension = "ts";

return Path.ChangeExtension(targetFile, "." + extension);
}
Expand Down Expand Up @@ -211,7 +185,7 @@ private string GetCommandLineArgs(MediaSourceInfo mediaSource, string inputTempF
}

var videoStream = mediaSource.VideoStream;
var videoDecoder = videoStream == null ? null : new EncodingHelper(_mediaEncoder, _fileSystem, null, _appPaths, _assemblyInfo).GetVideoDecoder(VideoType.VideoFile, videoStream, GetEncodingOptions());
string videoDecoder = null;

if (!string.IsNullOrEmpty(videoDecoder))
{
Expand Down Expand Up @@ -258,39 +232,27 @@ private string GetAudioArgs(MediaSourceInfo mediaSource)
var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>();
var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty;

// do not copy aac because many players have difficulty with aac_latm
if (_liveTvOptions.EnableOriginalAudioWithEncodedRecordings && !string.Equals(inputAudioCodec, "aac", StringComparison.OrdinalIgnoreCase))
{
return "-codec:a:0 copy";
}
return "-codec:a:0 copy";

var audioChannels = 2;
var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
if (audioStream != null)
{
audioChannels = audioStream.Channels ?? audioChannels;
}
return "-codec:a:0 aac -strict experimental -ab 320000";
//var audioChannels = 2;
//var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
//if (audioStream != null)
//{
// audioChannels = audioStream.Channels ?? audioChannels;
//}
//return "-codec:a:0 aac -strict experimental -ab 320000";
}

private bool EncodeVideo(MediaSourceInfo mediaSource)
{
var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>();
return !mediaStreams.Any(i => i.Type == MediaStreamType.Video && string.Equals(i.Codec, "h264", StringComparison.OrdinalIgnoreCase) && !i.IsInterlaced);
return false;
}

protected string GetOutputSizeParam()
{
var filters = new List<string>();

if (string.Equals(GetEncodingOptions().DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase))
{
filters.Add("yadif=1:-1:0");
}
else
{
filters.Add("yadif=0:-1:0");
}

filters.Add("yadif=0:-1:0");

var output = string.Empty;

Expand Down
2 changes: 2 additions & 0 deletions Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static string GetRecordingName(TimerInfo info)

private static string GetDateString(DateTime date)
{
date = date.ToLocalTime();

return string.Format("{0}_{1}_{2}_{3}_{4}_{5}",
date.Year.ToString("0000", CultureInfo.InvariantCulture),
date.Month.ToString("00", CultureInfo.InvariantCulture),
Expand Down
11 changes: 10 additions & 1 deletion Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,21 @@ private ProgramInfo GetProgram(string channelId, ScheduleDirect.Program programI
}
}

if (!string.IsNullOrWhiteSpace(details.originalAirDate) && (!info.IsSeries || info.IsRepeat))
if (!string.IsNullOrWhiteSpace(details.originalAirDate))
{
info.OriginalAirDate = DateTime.Parse(details.originalAirDate);
info.ProductionYear = info.OriginalAirDate.Value.Year;
}

if (details.movie != null)
{
int year;
if (!string.IsNullOrEmpty(details.movie.year) && int.TryParse(details.movie.year, out year))
{
info.ProductionYear = year;
}
}

if (details.genres != null)
{
info.Genres = details.genres.Where(g => !string.IsNullOrWhiteSpace(g)).ToList();
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Localization/Core/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Channels": "Kan\u00e1ly",
"Movies": "Filmy",
"Albums": "Alba",
"NameSeasonUnknown": "Season Unknown",
"NameSeasonUnknown": "Nezn\u00e1m\u00e1 sez\u00f3na",
"Artists": "Um\u011blci",
"Folders": "Slo\u017eky",
"Songs": "Skladby",
Expand Down
4 changes: 2 additions & 2 deletions Emby.Server.Implementations/Localization/Core/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Channels": "Kan\u00e4le",
"Movies": "Filme",
"Albums": "Alben",
"NameSeasonUnknown": "Season Unknown",
"NameSeasonUnknown": "Staffel unbekannt",
"Artists": "Interpreten",
"Folders": "Verzeichnisse",
"Songs": "Songs",
Expand Down Expand Up @@ -54,7 +54,7 @@
"UserCreatedWithName": "Benutzer {0} wurde erstellt",
"UserPasswordChangedWithName": "Das Passwort f\u00fcr Benutzer {0} wurde ge\u00e4ndert",
"UserDeletedWithName": "Benutzer {0} wurde gel\u00f6scht",
"UserPolicyUpdatedWithName": "User policy has been updated for {0}",
"UserPolicyUpdatedWithName": "Benutzerrichtlinie wurde f\u00fcr {0} aktualisiert",
"MessageServerConfigurationUpdated": "Server Einstellungen wurden aktualisiert",
"MessageNamedServerConfigurationUpdatedWithValue": "Der Server Einstellungsbereich {0} wurde aktualisiert",
"MessageApplicationUpdated": "Emby Server wurde auf den neusten Stand gebracht.",
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Localization/Core/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"LabelIpAddressValue": "IP adresa: {0}",
"DeviceOnlineWithName": "{0} je pripojen\u00fd",
"UserOnlineFromDevice": "{0} je online z {1}",
"ProviderValue": "Provider: {0}",
"ProviderValue": "Poskytovate\u013e: {0}",
"SubtitlesDownloadedForItem": "Titulky pre {0} stiahnut\u00e9",
"UserCreatedWithName": "Pou\u017e\u00edvate\u013e {0} bol vytvoren\u00fd",
"UserPasswordChangedWithName": "Heslo pou\u017e\u00edvate\u013ea {0} zmenen\u00e9",
Expand Down
27 changes: 0 additions & 27 deletions MediaBrowser.Api/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Services;
Expand Down Expand Up @@ -59,20 +55,6 @@ public class GetDefaultMetadataOptions : IReturn<MetadataOptions>

}

[Route("/System/Configuration/MetadataPlugins", "GET", Summary = "Gets all available metadata plugins")]
[Authenticated(Roles = "Admin")]
public class GetMetadataPlugins : IReturn<MetadataPluginSummary[]>
{

}

[Route("/System/Configuration/MetadataPlugins/Autoset", "POST")]
[Authenticated(Roles = "Admin", AllowBeforeStartupWizard = true)]
public class AutoSetMetadataOptions : IReturnVoid
{

}

[Route("/System/MediaEncoder/Path", "POST", Summary = "Updates the path to the media encoder")]
[Authenticated(Roles = "Admin", AllowBeforeStartupWizard = true)]
public class UpdateMediaEncoderPath : IReturnVoid
Expand Down Expand Up @@ -132,10 +114,6 @@ public object Get(GetNamedConfiguration request)
return ToOptimizedResult(result);
}

public void Post(AutoSetMetadataOptions request)
{
}

/// <summary>
/// Posts the specified configuraiton.
/// </summary>
Expand Down Expand Up @@ -164,10 +142,5 @@ public object Get(GetDefaultMetadataOptions request)
{
return ToOptimizedSerializedResultUsingCache(new MetadataOptions());
}

public object Get(GetMetadataPlugins request)
{
return ToOptimizedSerializedResultUsingCache(_providerManager.GetAllMetadataPlugins());
}
}
}
3 changes: 1 addition & 2 deletions MediaBrowser.Api/ItemLookupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ public void Post(ApplySearchCriteria request)
ImageRefreshMode = MetadataRefreshMode.FullRefresh,
ReplaceAllMetadata = true,
ReplaceAllImages = request.ReplaceAllImages,
SearchResult = request,
ForceEnableInternetMetadata = true
SearchResult = request

}, CancellationToken.None);
Task.WaitAll(task);
Expand Down
Loading

0 comments on commit 9800cc3

Please sign in to comment.