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