commit
17de021561
|
@ -7,6 +7,7 @@ using ServiceStack;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Session;
|
||||||
|
|
||||||
namespace MediaBrowser.Api
|
namespace MediaBrowser.Api
|
||||||
{
|
{
|
||||||
|
@ -76,12 +77,12 @@ namespace MediaBrowser.Api
|
||||||
public class ConnectService : BaseApiService
|
public class ConnectService : BaseApiService
|
||||||
{
|
{
|
||||||
private readonly IConnectManager _connectManager;
|
private readonly IConnectManager _connectManager;
|
||||||
private readonly IUserManager _userManager;
|
private readonly ISessionManager _sessionManager;
|
||||||
|
|
||||||
public ConnectService(IConnectManager connectManager, IUserManager userManager)
|
public ConnectService(IConnectManager connectManager, ISessionManager sessionManager)
|
||||||
{
|
{
|
||||||
_connectManager = connectManager;
|
_connectManager = connectManager;
|
||||||
_userManager = userManager;
|
_sessionManager = sessionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Post(CreateConnectLink request)
|
public object Post(CreateConnectLink request)
|
||||||
|
@ -141,11 +142,34 @@ namespace MediaBrowser.Api
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(auth.Client))
|
||||||
|
{
|
||||||
return ToOptimizedResult(new ConnectAuthenticationExchangeResult
|
return ToOptimizedResult(new ConnectAuthenticationExchangeResult
|
||||||
{
|
{
|
||||||
AccessToken = user.ConnectAccessKey,
|
AccessToken = user.ConnectAccessKey,
|
||||||
LocalUserId = user.Id.ToString("N")
|
LocalUserId = user.Id.ToString("N")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var session = await _sessionManager.CreateNewSession(new AuthenticationRequest
|
||||||
|
{
|
||||||
|
App = auth.Client,
|
||||||
|
AppVersion = auth.Version,
|
||||||
|
DeviceId = auth.DeviceId,
|
||||||
|
DeviceName = auth.Device,
|
||||||
|
RemoteEndPoint = Request.RemoteIp,
|
||||||
|
Username = user.Name,
|
||||||
|
UserId = user.Id.ToString("N")
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return ToOptimizedResult(new ConnectAuthenticationExchangeResult
|
||||||
|
{
|
||||||
|
AccessToken = session.AccessToken,
|
||||||
|
LocalUserId = session.User.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,5 +82,21 @@ namespace MediaBrowser.Controller.LiveTv
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The priority.</value>
|
/// <value>The priority.</value>
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// Program properties
|
||||||
|
public int? SeasonNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the episode number.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The episode number.</value>
|
||||||
|
public int? EpisodeNumber { get; set; }
|
||||||
|
public bool IsMovie { get; set; }
|
||||||
|
public bool IsKids { get; set; }
|
||||||
|
public bool IsSports { get; set; }
|
||||||
|
public int? ProductionYear { get; set; }
|
||||||
|
public string EpisodeTitle { get; set; }
|
||||||
|
public DateTime? OriginalAirDate { get; set; }
|
||||||
|
public bool IsProgramSeries { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace MediaBrowser.Controller.Session
|
||||||
public class AuthenticationRequest
|
public class AuthenticationRequest
|
||||||
{
|
{
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
public string PasswordSha1 { get; set; }
|
public string PasswordSha1 { get; set; }
|
||||||
public string PasswordMd5 { get; set; }
|
public string PasswordMd5 { get; set; }
|
||||||
public string App { get; set; }
|
public string App { get; set; }
|
||||||
|
|
|
@ -256,6 +256,8 @@ namespace MediaBrowser.Dlna.Main
|
||||||
|
|
||||||
foreach (var fullService in services)
|
foreach (var fullService in services)
|
||||||
{
|
{
|
||||||
|
_logger.Info("Registering publisher for {0} on {1}", fullService, addressString);
|
||||||
|
|
||||||
var descriptorURI = "/dlna/" + udn + "/description.xml";
|
var descriptorURI = "/dlna/" + udn + "/description.xml";
|
||||||
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);
|
var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);
|
||||||
|
|
||||||
|
|
|
@ -547,8 +547,6 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
refreshResult.Failures++;
|
|
||||||
|
|
||||||
Logger.ErrorException("Error in {0}", ex, provider.Name);
|
Logger.ErrorException("Error in {0}", ex, provider.Name);
|
||||||
|
|
||||||
// If a local provider fails, consider that a failure
|
// If a local provider fails, consider that a failure
|
||||||
|
|
|
@ -2552,7 +2552,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
throw new ArgumentNullException("to");
|
throw new ArgumentNullException("to");
|
||||||
}
|
}
|
||||||
|
|
||||||
var newPath = path.Replace(from, to, StringComparison.OrdinalIgnoreCase);
|
var newPath = path.Replace(from.Trim(), to.Trim(), StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (!string.Equals(newPath, path))
|
if (!string.Equals(newPath, path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -461,11 +461,29 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
return CreateSeriesTimer(info, cancellationToken);
|
return CreateSeriesTimer(info, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<string> CreateTimer(TimerInfo info, CancellationToken cancellationToken)
|
public Task<string> CreateTimer(TimerInfo timer, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
info.Id = Guid.NewGuid().ToString("N");
|
timer.Id = Guid.NewGuid().ToString("N");
|
||||||
_timerProvider.Add(info);
|
|
||||||
return Task.FromResult(info.Id);
|
ProgramInfo programInfo = null;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(timer.ProgramId))
|
||||||
|
{
|
||||||
|
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
||||||
|
}
|
||||||
|
if (programInfo == null)
|
||||||
|
{
|
||||||
|
_logger.Info("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
|
||||||
|
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (programInfo != null)
|
||||||
|
{
|
||||||
|
RecordingHelper.CopyProgramInfoToTimerInfo(programInfo, timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
_timerProvider.Add(timer);
|
||||||
|
return Task.FromResult(timer.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> CreateSeriesTimer(SeriesTimerInfo info, CancellationToken cancellationToken)
|
public async Task<string> CreateSeriesTimer(SeriesTimerInfo info, CancellationToken cancellationToken)
|
||||||
|
@ -849,12 +867,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRecordingPath(TimerInfo timer, ProgramInfo info)
|
private string GetRecordingPath(TimerInfo timer)
|
||||||
{
|
{
|
||||||
var recordPath = RecordingPath;
|
var recordPath = RecordingPath;
|
||||||
var config = GetConfiguration();
|
var config = GetConfiguration();
|
||||||
|
|
||||||
if (info.IsSeries)
|
if (timer.IsProgramSeries)
|
||||||
{
|
{
|
||||||
var customRecordingPath = config.SeriesRecordingPath;
|
var customRecordingPath = config.SeriesRecordingPath;
|
||||||
var allowSubfolder = true;
|
var allowSubfolder = true;
|
||||||
|
@ -869,29 +887,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
recordPath = Path.Combine(recordPath, "Series");
|
recordPath = Path.Combine(recordPath, "Series");
|
||||||
}
|
}
|
||||||
|
|
||||||
var folderName = _fileSystem.GetValidFilename(info.Name).Trim();
|
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim();
|
||||||
var folderNameWithYear = folderName;
|
|
||||||
if (info.ProductionYear.HasValue)
|
|
||||||
{
|
|
||||||
folderNameWithYear += " (" + info.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Directory.Exists(Path.Combine(recordPath, folderName)))
|
// Can't use the year here in the folder name because it is the year of the episode, not the series.
|
||||||
{
|
|
||||||
recordPath = Path.Combine(recordPath, folderName);
|
recordPath = Path.Combine(recordPath, folderName);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
recordPath = Path.Combine(recordPath, folderNameWithYear);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.SeasonNumber.HasValue)
|
if (timer.SeasonNumber.HasValue)
|
||||||
{
|
{
|
||||||
folderName = string.Format("Season {0}", info.SeasonNumber.Value.ToString(CultureInfo.InvariantCulture));
|
folderName = string.Format("Season {0}", timer.SeasonNumber.Value.ToString(CultureInfo.InvariantCulture));
|
||||||
recordPath = Path.Combine(recordPath, folderName);
|
recordPath = Path.Combine(recordPath, folderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (info.IsMovie)
|
else if (timer.IsMovie)
|
||||||
{
|
{
|
||||||
var customRecordingPath = config.MovieRecordingPath;
|
var customRecordingPath = config.MovieRecordingPath;
|
||||||
var allowSubfolder = true;
|
var allowSubfolder = true;
|
||||||
|
@ -906,34 +913,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
recordPath = Path.Combine(recordPath, "Movies");
|
recordPath = Path.Combine(recordPath, "Movies");
|
||||||
}
|
}
|
||||||
|
|
||||||
var folderName = _fileSystem.GetValidFilename(info.Name).Trim();
|
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim();
|
||||||
if (info.ProductionYear.HasValue)
|
if (timer.ProductionYear.HasValue)
|
||||||
{
|
{
|
||||||
folderName += " (" + info.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
|
folderName += " (" + timer.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
|
||||||
}
|
}
|
||||||
recordPath = Path.Combine(recordPath, folderName);
|
recordPath = Path.Combine(recordPath, folderName);
|
||||||
}
|
}
|
||||||
else if (info.IsKids)
|
else if (timer.IsKids)
|
||||||
{
|
{
|
||||||
if (config.EnableRecordingSubfolders)
|
if (config.EnableRecordingSubfolders)
|
||||||
{
|
{
|
||||||
recordPath = Path.Combine(recordPath, "Kids");
|
recordPath = Path.Combine(recordPath, "Kids");
|
||||||
}
|
}
|
||||||
|
|
||||||
var folderName = _fileSystem.GetValidFilename(info.Name).Trim();
|
var folderName = _fileSystem.GetValidFilename(timer.Name).Trim();
|
||||||
if (info.ProductionYear.HasValue)
|
if (timer.ProductionYear.HasValue)
|
||||||
{
|
{
|
||||||
folderName += " (" + info.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
|
folderName += " (" + timer.ProductionYear.Value.ToString(CultureInfo.InvariantCulture) + ")";
|
||||||
}
|
}
|
||||||
recordPath = Path.Combine(recordPath, folderName);
|
recordPath = Path.Combine(recordPath, folderName);
|
||||||
}
|
}
|
||||||
else if (info.IsSports)
|
else if (timer.IsSports)
|
||||||
{
|
{
|
||||||
if (config.EnableRecordingSubfolders)
|
if (config.EnableRecordingSubfolders)
|
||||||
{
|
{
|
||||||
recordPath = Path.Combine(recordPath, "Sports");
|
recordPath = Path.Combine(recordPath, "Sports");
|
||||||
}
|
}
|
||||||
recordPath = Path.Combine(recordPath, _fileSystem.GetValidFilename(info.Name).Trim());
|
recordPath = Path.Combine(recordPath, _fileSystem.GetValidFilename(timer.Name).Trim());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -941,10 +948,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
recordPath = Path.Combine(recordPath, "Other");
|
recordPath = Path.Combine(recordPath, "Other");
|
||||||
}
|
}
|
||||||
recordPath = Path.Combine(recordPath, _fileSystem.GetValidFilename(info.Name).Trim());
|
recordPath = Path.Combine(recordPath, _fileSystem.GetValidFilename(timer.Name).Trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)).Trim() + ".ts";
|
var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer)).Trim() + ".ts";
|
||||||
|
|
||||||
return Path.Combine(recordPath, recordingFileName);
|
return Path.Combine(recordPath, recordingFileName);
|
||||||
}
|
}
|
||||||
|
@ -956,29 +963,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
throw new ArgumentNullException("timer");
|
throw new ArgumentNullException("timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramInfo info = null;
|
ProgramInfo programInfo = null;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(timer.ProgramId))
|
if (!string.IsNullOrWhiteSpace(timer.ProgramId))
|
||||||
{
|
{
|
||||||
_logger.Info("Timer {0} has null programId", timer.Id);
|
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
||||||
}
|
}
|
||||||
else
|
if (programInfo == null)
|
||||||
{
|
|
||||||
info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info == null)
|
|
||||||
{
|
{
|
||||||
_logger.Info("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
|
_logger.Info("Unable to find program with Id {0}. Will search using start date", timer.ProgramId);
|
||||||
info = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
|
programInfo = GetProgramInfoFromCache(timer.ChannelId, timer.StartDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info == null)
|
if (programInfo != null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(string.Format("Program with Id {0} not found", timer.ProgramId));
|
RecordingHelper.CopyProgramInfoToTimerInfo(programInfo, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var recordPath = GetRecordingPath(timer, info);
|
var recordPath = GetRecordingPath(timer);
|
||||||
var recordingStatus = RecordingStatus.New;
|
var recordingStatus = RecordingStatus.New;
|
||||||
var isResourceOpen = false;
|
var isResourceOpen = false;
|
||||||
SemaphoreSlim semaphore = null;
|
SemaphoreSlim semaphore = null;
|
||||||
|
@ -1062,7 +1064,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
timer.Status = RecordingStatus.Completed;
|
timer.Status = RecordingStatus.Completed;
|
||||||
_timerProvider.Delete(timer);
|
_timerProvider.Delete(timer);
|
||||||
|
|
||||||
OnSuccessfulRecording(info.IsSeries, recordPath);
|
OnSuccessfulRecording(timer.IsProgramSeries, recordPath);
|
||||||
}
|
}
|
||||||
else if (DateTime.UtcNow < timer.EndDate)
|
else if (DateTime.UtcNow < timer.EndDate)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,19 +30,29 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
timer.Overview = parent.Overview;
|
timer.Overview = parent.Overview;
|
||||||
timer.SeriesTimerId = series.Id;
|
timer.SeriesTimerId = series.Id;
|
||||||
|
|
||||||
|
CopyProgramInfoToTimerInfo(parent, timer);
|
||||||
|
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetRecordingName(TimerInfo timer, ProgramInfo info)
|
public static void CopyProgramInfoToTimerInfo(ProgramInfo programInfo, TimerInfo timerInfo)
|
||||||
{
|
{
|
||||||
if (info == null)
|
timerInfo.SeasonNumber = programInfo.SeasonNumber;
|
||||||
{
|
timerInfo.EpisodeNumber = programInfo.EpisodeNumber;
|
||||||
return timer.ProgramId;
|
timerInfo.IsMovie = programInfo.IsMovie;
|
||||||
|
timerInfo.IsKids = programInfo.IsKids;
|
||||||
|
timerInfo.IsSports = programInfo.IsSports;
|
||||||
|
timerInfo.ProductionYear = programInfo.ProductionYear;
|
||||||
|
timerInfo.EpisodeTitle = programInfo.EpisodeTitle;
|
||||||
|
timerInfo.OriginalAirDate = programInfo.OriginalAirDate;
|
||||||
|
timerInfo.IsProgramSeries = programInfo.IsSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetRecordingName(TimerInfo info)
|
||||||
|
{
|
||||||
var name = info.Name;
|
var name = info.Name;
|
||||||
|
|
||||||
if (info.IsSeries)
|
if (info.IsProgramSeries)
|
||||||
{
|
{
|
||||||
var addHyphen = true;
|
var addHyphen = true;
|
||||||
|
|
||||||
|
|
|
@ -1341,8 +1341,19 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
|
|
||||||
private async Task<AuthenticationResult> AuthenticateNewSessionInternal(AuthenticationRequest request, bool enforcePassword)
|
private async Task<AuthenticationResult> AuthenticateNewSessionInternal(AuthenticationRequest request, bool enforcePassword)
|
||||||
{
|
{
|
||||||
var user = _userManager.Users
|
User user = null;
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.UserId))
|
||||||
|
{
|
||||||
|
var idGuid = new Guid(request.UserId);
|
||||||
|
user = _userManager.Users
|
||||||
|
.FirstOrDefault(i => i.Id == idGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = _userManager.Users
|
||||||
.FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
if (user != null && !string.IsNullOrWhiteSpace(request.DeviceId))
|
if (user != null && !string.IsNullOrWhiteSpace(request.DeviceId))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user