mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Upcoming view column width fixed for Air Date (added time).
This commit is contained in:
parent
975d8bc679
commit
ff0e0597b4
4 changed files with 318 additions and 292 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
@ -76,7 +77,7 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
series.SeriesId = tvDbSeries.Id;
|
||||
series.Title = tvDbSeries.SeriesName;
|
||||
series.AirTimes = tvDbSeries.AirsTime;
|
||||
series.AirTimes = CleanAirsTime(tvDbSeries.AirsTime);
|
||||
series.AirsDayOfWeek = tvDbSeries.AirsDayOfWeek;
|
||||
series.Overview = tvDbSeries.Overview;
|
||||
series.Status = tvDbSeries.Status;
|
||||
|
@ -155,5 +156,29 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up the AirsTime Component from TheTVDB since it can be garbage that comes in.
|
||||
/// </summary>
|
||||
/// <param name = "input">The TVDB AirsTime</param>
|
||||
/// <returns>String that contains the AirTimes</returns>
|
||||
private string CleanAirsTime(string inputTime)
|
||||
{
|
||||
Regex timeRegex = new Regex(@"^(?<time>\d+:?\d*)\W*(?<meridiem>am|pm)?", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
var match = timeRegex.Match(inputTime);
|
||||
var time = match.Groups["time"].Value;
|
||||
var meridiem = match.Groups["meridiem"].Value;
|
||||
|
||||
//Lets assume that a string that doesn't contain a Merideim is aired at night... So we'll add it
|
||||
if (String.IsNullOrEmpty(meridiem))
|
||||
meridiem = "PM";
|
||||
|
||||
if (String.IsNullOrEmpty(time))
|
||||
return String.Empty;
|
||||
|
||||
var dateTime = DateTime.Parse(time + " " + meridiem);
|
||||
return dateTime.ToString("hh:mm tt");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue