jellyfin-server/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs

62 lines
2.1 KiB
C#
Raw Normal View History

2015-07-29 03:42:03 +00:00
using MediaBrowser.Common.Extensions;
2015-07-20 18:32:55 +00:00
using MediaBrowser.Controller.LiveTv;
using System;
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)
{
return (timer.ProgramId + ".ts");
}
var fancyName = info.Name;
if (info.ProductionYear != null)
{
fancyName += "_(" + info.ProductionYear + ")";
}
2015-08-16 00:41:55 +00:00
if (info.IsSeries && !string.IsNullOrWhiteSpace(info.EpisodeTitle))
2015-07-20 18:32:55 +00:00
{
fancyName += "_" + info.EpisodeTitle.Replace("Season: ", "S").Replace(" Episode: ", "E");
}
if (info.IsHD ?? false)
{
fancyName += "_HD";
}
if (info.OriginalAirDate != null)
{
fancyName += "_" + info.OriginalAirDate.Value.ToString("yyyy-MM-dd");
}
2015-08-16 00:41:55 +00:00
return fancyName + ".ts";
2015-07-20 18:32:55 +00:00
}
}
}