Skip to content
Permalink
Browse files

Merge remote-tracking branch 'remotes/origin/MP1-4973-ImproveXmlTv' i…

…nto MP_1.23.100_Pre_Release_Test4+PR
  • Loading branch information
Azzuro committed Dec 31, 2019
2 parents fcdc9bc + 28aae37 commit de4143886d615b4e78ad363181b0bdb0787a04d6
@@ -90,6 +90,7 @@ public DateTime EndTime
private TvBusinessLayer layer = new TvBusinessLayer();

private static bool _isImporting = false;
private bool _skipTextProcessing;

public XMLTVImport()
: this(0) {}
@@ -200,6 +201,7 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)
int hours = Int32.Parse(layer.GetSetting("xmlTvTimeZoneHours", "0").Value);
int mins = Int32.Parse(layer.GetSetting("xmlTvTimeZoneMins", "0").Value);
int timeZoneCorrection = hours * 60 + mins;
_skipTextProcessing = layer.GetSetting("xmlTvNoTextMod", "false").Value == "true";

ArrayList Programs = new ArrayList();
Dictionary<int, ChannelPrograms> dChannelPrograms = new Dictionary<int, ChannelPrograms>();
@@ -328,6 +330,7 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)

SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Channel));
sb.AddOrderByField(true, "externalId");
sb.AddConstraint("visibleInGuide = 1");
sb.AddConstraint("externalId IS NOT null");
sb.AddConstraint(Operator.NotEquals, "externalId", "");

@@ -523,6 +526,7 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)
startDate = 100 * Int64.Parse(nodeStart.Substring(0, 12)); //200403312220
}

bool hasStopDate = false;
long stopDate = startDate;
if (nodeStop != null)
{
@@ -532,10 +536,12 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)
stopDate = Int64.Parse(nodeStop.Substring(0, 14)); //20040331222000
else
stopDate = 100 * Int64.Parse(nodeStop.Substring(0, 12)); //200403312220
hasStopDate = true;
}
else if (nodeStop.Length >= 12)
{
stopDate = 100 * Int64.Parse(nodeStop.Substring(0, 12)); //200403312220
hasStopDate = true;
}
}

@@ -684,28 +690,15 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)
// get the channel program
channelPrograms = dChannelPrograms[chan.IdChannel];

if (chan.IdChannel < 0)
// skip invalid programs with same start/end date
if (chan.IdChannel < 0 || hasStopDate && startDate == stopDate)
{
continue;
}

title = title.Replace("\r\n", " ");
title = title.Replace("\n\r", " ");
title = title.Replace("\r", " ");
title = title.Replace("\n", " ");
title = title.Replace(" ", " ");

description = description.Replace("\r\n", " ");
description = description.Replace("\n\r", " ");
description = description.Replace("\r", " ");
description = description.Replace("\n", " ");
description = description.Replace(" ", " ");

episodeName = episodeName.Replace("\r\n", " ");
episodeName = episodeName.Replace("\n\r", " ");
episodeName = episodeName.Replace("\r", " ");
episodeName = episodeName.Replace("\n", " ");
episodeName = episodeName.Replace(" ", " ");
title = ProcessText(title);
description = ProcessText(description);
episodeName = ProcessText(episodeName);

Program prog = new Program(chan.IdChannel, longtodate(startDate), longtodate(stopDate), title,
description, category, Program.ProgramState.None,
@@ -858,6 +851,24 @@ public bool Import(string fileName, bool deleteBeforeImport, bool showProgress)
return result;
}

/// <summary>
/// Removes newlines and duplicated spaces from given <paramref name="text"/>. This method only modifies content if
/// setting "xmlTvNoTextMod" is <c>false</c>.
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
protected string ProcessText(string text)
{
if (_skipTextProcessing)
return text;
text = text.Replace("\r\n", " ");
text = text.Replace("\n\r", " ");
text = text.Replace("\r", " ");
text = text.Replace("\n", " ");
text = text.Replace(" ", " ");
return text;
}

/// <summary>
/// Parse and correct ep. # in the episode string
/// </summary>

Some generated files are not rendered by default. Learn more.

@@ -69,6 +69,10 @@ public override void OnSectionDeActivated()
setting.Value = cbImportLST.Checked ? "true" : "false";
setting.Persist();

setting = layer.GetSetting("xmlTvNoTextMod", "true");
setting.Value = cbNoTextMod.Checked ? "true" : "false";
setting.Persist();

setting = layer.GetSetting("xmlTvTimeZoneHours", "0");
setting.Value = textBoxHours.Text;
setting.Persist();
@@ -130,6 +134,7 @@ public override void OnSectionActivated()
checkBox1.Checked = layer.GetSetting("xmlTvUseTimeZone", "false").Value == "true";
cbImportXML.Checked = layer.GetSetting("xmlTvImportXML", "true").Value == "true";
cbImportLST.Checked = layer.GetSetting("xmlTvImportLST", "false").Value == "true";
cbNoTextMod.Checked = layer.GetSetting("xmlTvNoTextMod", "false").Value == "true";
checkBoxDeleteBeforeImport.Checked = layer.GetSetting("xmlTvDeleteBeforeImport", "true").Value == "true";

textBoxHours.Text = layer.GetSetting("xmlTvTimeZoneHours", "0").Value;
@@ -261,7 +266,7 @@ private void buttonRefresh_Click(object sender, EventArgs e)
String.Format(
"select c.* from Channel c join GroupMap g on c.idChannel=g.idChannel where " +
(loadRadio ? "" : " c.isTv = 1 and ") +
" g.idGroup = '{0}' order by g.sortOrder", chGroup.idGroup),
" g.idGroup = '{0}' and c.visibleInGuide = 1 order by g.sortOrder", chGroup.idGroup),
typeof (Channel));
channels = ObjectFactory.GetCollection<Channel>(ManualJoinSQL.Execute());
}
@@ -271,6 +276,7 @@ private void buttonRefresh_Click(object sender, EventArgs e)
sb.AddOrderByField(true, "sortOrder");
if (!loadRadio)
sb.AddConstraint(" isTv = 1");
sb.AddConstraint(" visibleInGuide = 1");
SqlStatement stmt = sb.GetStatement(true);
channels = ObjectFactory.GetCollection<Channel>(stmt.Execute());
}
@@ -112,30 +112,30 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tuningChannel.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="tuningChannel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="guideChannel.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="guideChannel.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="matchType.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="matchType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ShowInGuide.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="ShowInGuide.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="saveFileExport.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="saveFileExport.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="folderBrowserDialogTVGuide.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="folderBrowserDialogTVGuide.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>146, 17</value>
</metadata>
</root>

0 comments on commit de41438

Please sign in to comment.
You can’t perform that action at this time.