2015-07-28 20:42:03 -07:00
|
|
|
|
using MediaBrowser.Common.Extensions;
|
2015-07-20 11:32:55 -07:00
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
|
|
|
|
using System;
|
2015-08-20 16:55:23 -07:00
|
|
|
|
using System.Globalization;
|
2015-07-20 11:32:55 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|
|
|
|
{
|
|
|
|
|
internal class RecordingHelper
|
|
|
|
|
{
|
|
|
|
|
public static DateTime GetStartTime(TimerInfo timer)
|
|
|
|
|
{
|
|
|
|
|
return timer.StartDate.AddSeconds(-timer.PrePaddingSeconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TimerInfo CreateTimer(ProgramInfo parent, SeriesTimerInfo series)
|
|
|
|
|
{
|
|
|
|
|
var timer = new TimerInfo();
|
|
|
|
|
|
|
|
|
|
timer.ChannelId = parent.ChannelId;
|
|
|
|
|
timer.Id = (series.Id + parent.Id).GetMD5().ToString("N");
|
|
|
|
|
timer.StartDate = parent.StartDate;
|
|
|
|
|
timer.EndDate = parent.EndDate;
|
|
|
|
|
timer.ProgramId = parent.Id;
|
|
|
|
|
timer.PrePaddingSeconds = series.PrePaddingSeconds;
|
|
|
|
|
timer.PostPaddingSeconds = series.PostPaddingSeconds;
|
|
|
|
|
timer.IsPostPaddingRequired = series.IsPostPaddingRequired;
|
|
|
|
|
timer.IsPrePaddingRequired = series.IsPrePaddingRequired;
|
|
|
|
|
timer.Priority = series.Priority;
|
|
|
|
|
timer.Name = parent.Name;
|
|
|
|
|
timer.Overview = parent.Overview;
|
|
|
|
|
timer.SeriesTimerId = series.Id;
|
|
|
|
|
|
|
|
|
|
return timer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetRecordingName(TimerInfo timer, ProgramInfo info)
|
|
|
|
|
{
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
2015-08-20 19:36:30 -07:00
|
|
|
|
return timer.ProgramId;
|
2015-07-20 11:32:55 -07:00
|
|
|
|
}
|
2015-08-20 16:55:23 -07:00
|
|
|
|
|
|
|
|
|
var name = info.Name;
|
|
|
|
|
|
|
|
|
|
if (info.IsSeries)
|
2015-07-20 11:32:55 -07:00
|
|
|
|
{
|
2015-08-25 19:13:28 -07:00
|
|
|
|
var addHyphen = true;
|
|
|
|
|
|
2015-08-20 16:55:23 -07:00
|
|
|
|
if (info.SeasonNumber.HasValue && info.EpisodeNumber.HasValue)
|
|
|
|
|
{
|
|
|
|
|
name += string.Format(" S{0}E{1}", info.SeasonNumber.Value.ToString("00", CultureInfo.InvariantCulture), info.EpisodeNumber.Value.ToString("00", CultureInfo.InvariantCulture));
|
2015-08-25 19:13:28 -07:00
|
|
|
|
addHyphen = false;
|
2015-08-20 16:55:23 -07:00
|
|
|
|
}
|
|
|
|
|
else if (info.OriginalAirDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
name += " " + info.OriginalAirDate.Value.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
2015-08-20 19:36:30 -07:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
|
2015-08-20 16:55:23 -07:00
|
|
|
|
{
|
2016-02-29 21:24:42 -07:00
|
|
|
|
if (addHyphen)
|
|
|
|
|
{
|
|
|
|
|
name += " -";
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 16:55:23 -07:00
|
|
|
|
name += " " + info.EpisodeTitle;
|
|
|
|
|
}
|
2015-07-20 11:32:55 -07:00
|
|
|
|
}
|
2015-08-20 16:55:23 -07:00
|
|
|
|
|
2015-09-21 18:05:33 -07:00
|
|
|
|
else if (info.IsMovie && info.ProductionYear != null)
|
2015-07-20 11:32:55 -07:00
|
|
|
|
{
|
2015-08-20 16:55:23 -07:00
|
|
|
|
name += " (" + info.ProductionYear + ")";
|
2015-07-20 11:32:55 -07:00
|
|
|
|
}
|
2015-09-21 18:05:33 -07:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-01-11 19:38:43 -07:00
|
|
|
|
name += " " + info.StartDate.ToString("yyyy-MM-dd") + " " + info.Id;
|
2015-09-21 18:05:33 -07:00
|
|
|
|
}
|
2015-08-20 16:55:23 -07:00
|
|
|
|
|
2015-08-20 19:36:30 -07:00
|
|
|
|
return name;
|
2015-07-20 11:32:55 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|