jellyfin/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs

77 lines
2.4 KiB
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2015-08-21 01:55:23 +02:00
using System.Globalization;
using MediaBrowser.Controller.LiveTv;
2015-07-20 20:32:55 +02:00
2016-11-04 00:35:19 +01:00
namespace Emby.Server.Implementations.LiveTv.EmbyTV
2015-07-20 20:32:55 +02:00
{
2021-05-15 21:49:04 +02:00
internal static class RecordingHelper
2015-07-20 20:32:55 +02:00
{
public static DateTime GetStartTime(TimerInfo timer)
{
return timer.StartDate.AddSeconds(-timer.PrePaddingSeconds);
}
2016-09-15 08:23:39 +02:00
public static string GetRecordingName(TimerInfo info)
{
2015-08-21 01:55:23 +02:00
var name = info.Name;
2016-09-15 08:23:39 +02:00
if (info.IsProgramSeries)
2015-07-20 20:32:55 +02:00
{
2015-08-26 04:13:28 +02:00
var addHyphen = true;
2015-08-21 01:55:23 +02:00
if (info.SeasonNumber.HasValue && info.EpisodeNumber.HasValue)
{
name += string.Format(
CultureInfo.InvariantCulture,
" S{0}E{1}",
info.SeasonNumber.Value.ToString("00", CultureInfo.InvariantCulture),
info.EpisodeNumber.Value.ToString("00", CultureInfo.InvariantCulture));
2015-08-26 04:13:28 +02:00
addHyphen = false;
2015-08-21 01:55:23 +02:00
}
else if (info.OriginalAirDate.HasValue)
{
2018-09-12 19:26:21 +02:00
if (info.OriginalAirDate.Value.Date.Equals(info.StartDate.Date))
{
name += " " + GetDateString(info.StartDate);
}
else
{
name += " " + info.OriginalAirDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
2018-09-12 19:26:21 +02:00
}
2015-08-21 01:55:23 +02:00
}
2016-08-29 20:42:53 +02:00
else
{
2018-09-12 19:26:21 +02:00
name += " " + GetDateString(info.StartDate);
2016-08-29 20:42:53 +02:00
}
2015-08-21 04:36:30 +02:00
if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
2015-08-21 01:55:23 +02:00
{
2016-03-01 05:24:42 +01:00
if (addHyphen)
{
name += " -";
}
2015-08-21 01:55:23 +02:00
name += " " + info.EpisodeTitle;
}
2015-07-20 20:32:55 +02:00
}
2015-09-22 03:05:33 +02:00
else if (info.IsMovie && info.ProductionYear != null)
2015-07-20 20:32:55 +02:00
{
2015-08-21 01:55:23 +02:00
name += " (" + info.ProductionYear + ")";
2015-07-20 20:32:55 +02:00
}
2015-09-22 03:05:33 +02:00
else
{
2018-09-12 19:26:21 +02:00
name += " " + GetDateString(info.StartDate);
2015-09-22 03:05:33 +02:00
}
2015-08-21 01:55:23 +02:00
2015-08-21 04:36:30 +02:00
return name;
2015-07-20 20:32:55 +02:00
}
2018-09-12 19:26:21 +02:00
private static string GetDateString(DateTime date)
{
2021-05-15 21:49:04 +02:00
return date.ToLocalTime().ToString("yyyy_MM_dd_HH_mm_ss", CultureInfo.InvariantCulture);
2018-09-12 19:26:21 +02:00
}
2015-07-20 20:32:55 +02:00
}
}