2020-02-06 07:20:23 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 12:54:44 -07:00
|
|
|
using System;
|
2015-08-20 16:55:23 -07:00
|
|
|
using System.Globalization;
|
2019-01-13 12:22:00 -07:00
|
|
|
using MediaBrowser.Controller.LiveTv;
|
2015-07-20 11:32:55 -07:00
|
|
|
|
2016-11-03 16:35:19 -07:00
|
|
|
namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
2015-07-20 11:32:55 -07:00
|
|
|
{
|
|
|
|
internal class RecordingHelper
|
|
|
|
{
|
|
|
|
public static DateTime GetStartTime(TimerInfo timer)
|
|
|
|
{
|
|
|
|
return timer.StartDate.AddSeconds(-timer.PrePaddingSeconds);
|
|
|
|
}
|
|
|
|
|
2016-09-14 23:23:39 -07:00
|
|
|
public static string GetRecordingName(TimerInfo info)
|
|
|
|
{
|
2015-08-20 16:55:23 -07:00
|
|
|
var name = info.Name;
|
|
|
|
|
2016-09-14 23:23:39 -07:00
|
|
|
if (info.IsProgramSeries)
|
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)
|
|
|
|
{
|
2020-02-06 07:20:23 -07: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 19:13:28 -07:00
|
|
|
addHyphen = false;
|
2015-08-20 16:55:23 -07:00
|
|
|
}
|
|
|
|
else if (info.OriginalAirDate.HasValue)
|
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
if (info.OriginalAirDate.Value.Date.Equals(info.StartDate.Date))
|
|
|
|
{
|
|
|
|
name += " " + GetDateString(info.StartDate);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-06 07:20:23 -07:00
|
|
|
name += " " + info.OriginalAirDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2015-08-20 16:55:23 -07:00
|
|
|
}
|
2016-08-29 11:42:53 -07:00
|
|
|
else
|
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
name += " " + GetDateString(info.StartDate);
|
2016-08-29 11:42:53 -07:00
|
|
|
}
|
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-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
|
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
name += " " + GetDateString(info.StartDate);
|
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
|
|
|
}
|
2018-09-12 10:26:21 -07:00
|
|
|
|
|
|
|
private static string GetDateString(DateTime date)
|
|
|
|
{
|
|
|
|
date = date.ToLocalTime();
|
|
|
|
|
2020-02-06 07:20:23 -07:00
|
|
|
return string.Format(
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
"{0}_{1}_{2}_{3}_{4}_{5}",
|
2018-09-12 10:26:21 -07:00
|
|
|
date.Year.ToString("0000", CultureInfo.InvariantCulture),
|
|
|
|
date.Month.ToString("00", CultureInfo.InvariantCulture),
|
|
|
|
date.Day.ToString("00", CultureInfo.InvariantCulture),
|
|
|
|
date.Hour.ToString("00", CultureInfo.InvariantCulture),
|
|
|
|
date.Minute.ToString("00", CultureInfo.InvariantCulture),
|
2020-02-06 07:20:23 -07:00
|
|
|
date.Second.ToString("00", CultureInfo.InvariantCulture));
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2015-07-20 11:32:55 -07:00
|
|
|
}
|
|
|
|
}
|