Skip to content

Commit

Permalink
Merge branch 'WIP_2.2' of https://github.com/MediaPortal/MediaPortal-2
Browse files Browse the repository at this point in the history
…into WIP_2.2
  • Loading branch information
henso96 committed Sep 19, 2018
2 parents 8cfb4ab + 14213c1 commit 53a94b6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 138 deletions.
4 changes: 2 additions & 2 deletions MediaPortal/Setup/CustomActions/CustomActionRunner.cs
Expand Up @@ -38,8 +38,8 @@ public class CustomActionRunner

private const string LAV_SPLITTER_REGISTRY_PATH = @"CLSID\{171252A0-8820-4AFE-9DF8-5C92B2D66B04}\InprocServer32";
private const string LAV_FILTERS_FILE_NAME = "LAVFilters.exe";
private const string LAV_FILTERS_URL = "http://install.team-mediaportal.com/MP2/install/LAVFilters.exe";
private const string LAV_FILTERS_METADATA_FILE = "http://install.team-mediaportal.com/MP2/install/metadata/LAVFilters.xml";
private const string LAV_FILTERS_URL = "http://install.team-mediaportal.com/MP2/install/LAVFilters-0.72.exe";
private const string LAV_FILTERS_METADATA_FILE = "http://install.team-mediaportal.com/MP2/install/metadata/LAVFilters-072.xml";
private const string LAV_FILTERS_XSD_FILE = "CustomActions.LAVFilters.xsd";

public CustomActionRunner(IRunnerHelper runnerHelper)
Expand Down
Expand Up @@ -99,7 +99,7 @@ public override async Task<bool> TryExtractMetadataAsync(IResourceAccessor media
EpisodeInfo episodeInfo = GetSeriesFromTags(tags);
if (episodeInfo.IsBaseInfoPresent)
{
if(!forceQuickMode)
if (!forceQuickMode)
await OnlineMatcherService.Instance.FindAndUpdateEpisodeAsync(episodeInfo).ConfigureAwait(false);
if (episodeInfo.IsBaseInfoPresent)
episodeInfo.SetMetadata(extractedAspectData);
Expand Down Expand Up @@ -168,6 +168,8 @@ public class Tags
const string TAG_EPISODENUM = "EPISODENUM";
const string TAG_STARTTIME = "STARTTIME";
const string TAG_ENDTIME = "ENDTIME";
const string TAG_PROGRAMSTARTTIME = "PROGRAMSTARTTIME";
const string TAG_PROGRAMENDTIME = "PROGRAMENDTIME";

#endregion

Expand Down Expand Up @@ -318,13 +320,37 @@ public virtual Task<bool> TryExtractMetadataAsync(IResourceAccessor mediaItemAcc
MediaItemAspect.SetAttribute(extractedAspectData, RecordingAspect.ATTR_CHANNEL, value);

// Recording date formatted: 2011-11-04 20:55
DateTime recordingStart;
DateTime recordingEnd;
if (TryGet(tags, TAG_STARTTIME, out value) && DateTime.TryParse(value, out recordingStart))
MediaItemAspect.SetAttribute(extractedAspectData, RecordingAspect.ATTR_STARTTIME, recordingStart);
DateTime tmpValue;
DateTime? recordingStart = null;
DateTime? recordingEnd = null;
DateTime? programStart = null;
DateTime? programEnd = null;

if (TryGet(tags, TAG_ENDTIME, out value) && DateTime.TryParse(value, out recordingEnd))
MediaItemAspect.SetAttribute(extractedAspectData, RecordingAspect.ATTR_ENDTIME, recordingEnd);
// First try to read program start and end times, they will be preferred.
if (TryGet(tags, TAG_PROGRAMSTARTTIME, out value) && DateTime.TryParse(value, out tmpValue))
programStart = tmpValue;

if (TryGet(tags, TAG_PROGRAMENDTIME, out value) && DateTime.TryParse(value, out tmpValue))
programEnd = tmpValue;

if (TryGet(tags, TAG_STARTTIME, out value) && DateTime.TryParse(value, out tmpValue))
recordingStart = tmpValue;

if (TryGet(tags, TAG_ENDTIME, out value) && DateTime.TryParse(value, out tmpValue))
recordingEnd = tmpValue;

// Correct start time if recording started before the program (skip pre-recording offset)
if (programStart.HasValue && recordingStart.HasValue && programStart > recordingStart)
recordingStart = programStart;

// Correct end time if recording ended after the program (skip the post-recording offset)
if (programEnd.HasValue && recordingEnd.HasValue && programEnd < recordingEnd)
recordingEnd = programEnd;

if (recordingStart.HasValue)
MediaItemAspect.SetAttribute(extractedAspectData, RecordingAspect.ATTR_STARTTIME, recordingStart.Value);
if (recordingEnd.HasValue)
MediaItemAspect.SetAttribute(extractedAspectData, RecordingAspect.ATTR_ENDTIME, recordingEnd.Value);

return Task.FromResult(true);
}
Expand Down

0 comments on commit 53a94b6

Please sign in to comment.