2015-07-29 05:42:03 +02:00
|
|
|
|
using MediaBrowser.Common.Extensions;
|
2015-07-20 20:32:55 +02:00
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
|
|
|
|
using System;
|
2015-08-21 01:55:23 +02:00
|
|
|
|
using System.Globalization;
|
2016-10-04 07:15:39 +02:00
|
|
|
|
using MediaBrowser.Model.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
|
|
|
|
{
|
|
|
|
|
internal class RecordingHelper
|
|
|
|
|
{
|
|
|
|
|
public static DateTime GetStartTime(TimerInfo timer)
|
|
|
|
|
{
|
|
|
|
|
return timer.StartDate.AddSeconds(-timer.PrePaddingSeconds);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 07:15:39 +02:00
|
|
|
|
public static TimerInfo CreateTimer(ProgramInfo parent, SeriesTimerInfo seriesTimer)
|
2015-07-20 20:32:55 +02:00
|
|
|
|
{
|
|
|
|
|
var timer = new TimerInfo();
|
|
|
|
|
|
|
|
|
|
timer.ChannelId = parent.ChannelId;
|
2016-10-04 07:15:39 +02:00
|
|
|
|
timer.Id = (seriesTimer.Id + parent.Id).GetMD5().ToString("N");
|
2015-07-20 20:32:55 +02:00
|
|
|
|
timer.StartDate = parent.StartDate;
|
|
|
|
|
timer.EndDate = parent.EndDate;
|
|
|
|
|
timer.ProgramId = parent.Id;
|
2016-10-04 07:15:39 +02:00
|
|
|
|
timer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds;
|
|
|
|
|
timer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds;
|
|
|
|
|
timer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired;
|
|
|
|
|
timer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired;
|
|
|
|
|
timer.KeepUntil = seriesTimer.KeepUntil;
|
|
|
|
|
timer.Priority = seriesTimer.Priority;
|
2015-07-20 20:32:55 +02:00
|
|
|
|
timer.Name = parent.Name;
|
|
|
|
|
timer.Overview = parent.Overview;
|
2016-10-04 07:15:39 +02:00
|
|
|
|
timer.SeriesTimerId = seriesTimer.Id;
|
2016-11-24 17:29:23 +01:00
|
|
|
|
timer.ShowId = parent.ShowId;
|
2015-07-20 20:32:55 +02:00
|
|
|
|
|
2016-09-15 08:23:39 +02:00
|
|
|
|
CopyProgramInfoToTimerInfo(parent, timer);
|
|
|
|
|
|
2015-07-20 20:32:55 +02:00
|
|
|
|
return timer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 08:23:39 +02:00
|
|
|
|
public static void CopyProgramInfoToTimerInfo(ProgramInfo programInfo, TimerInfo timerInfo)
|
2015-07-20 20:32:55 +02:00
|
|
|
|
{
|
2016-09-15 08:23:39 +02:00
|
|
|
|
timerInfo.SeasonNumber = programInfo.SeasonNumber;
|
|
|
|
|
timerInfo.EpisodeNumber = programInfo.EpisodeNumber;
|
|
|
|
|
timerInfo.IsMovie = programInfo.IsMovie;
|
|
|
|
|
timerInfo.IsKids = programInfo.IsKids;
|
2016-09-29 14:55:49 +02:00
|
|
|
|
timerInfo.IsNews = programInfo.IsNews;
|
2016-09-15 08:23:39 +02:00
|
|
|
|
timerInfo.IsSports = programInfo.IsSports;
|
|
|
|
|
timerInfo.ProductionYear = programInfo.ProductionYear;
|
|
|
|
|
timerInfo.EpisodeTitle = programInfo.EpisodeTitle;
|
|
|
|
|
timerInfo.OriginalAirDate = programInfo.OriginalAirDate;
|
|
|
|
|
timerInfo.IsProgramSeries = programInfo.IsSeries;
|
2016-09-20 21:38:53 +02:00
|
|
|
|
|
|
|
|
|
timerInfo.HomePageUrl = programInfo.HomePageUrl;
|
|
|
|
|
timerInfo.CommunityRating = programInfo.CommunityRating;
|
|
|
|
|
timerInfo.ShortOverview = programInfo.ShortOverview;
|
|
|
|
|
timerInfo.OfficialRating = programInfo.OfficialRating;
|
2016-10-04 07:15:39 +02:00
|
|
|
|
timerInfo.IsRepeat = programInfo.IsRepeat;
|
2016-09-15 08:23:39 +02:00
|
|
|
|
}
|
2015-08-21 01:55:23 +02:00
|
|
|
|
|
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(" 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)
|
|
|
|
|
{
|
|
|
|
|
name += " " + info.OriginalAirDate.Value.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
2016-08-29 20:42:53 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
name += " " + DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
|
}
|
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-08-21 01:55:23 +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
|
|
|
|
|
{
|
2016-01-12 03:38:43 +01:00
|
|
|
|
name += " " + info.StartDate.ToString("yyyy-MM-dd") + " " + info.Id;
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|