- fixed application of .txt reference lists (which had no effect at all on philips lists)

- improved support for Vidaa 5.1 Hisense format
This commit is contained in:
Horst Beham
2021-07-08 22:13:08 +02:00
parent 70811cf829
commit 0890c0f2c7
13 changed files with 136 additions and 25 deletions

View File

@@ -257,7 +257,7 @@ namespace ChanSort.Api
if (!(chanFilter?.Invoke(refChannel, true) ?? true))
continue;
var tvChannel = FindChannel(tvList, newPos, refChannel, onidTsidSid);
var tvChannel = FindChannel(tvList, newPos, refChannel, onidTsidSid, overwrite);
if (tvChannel != null)
{
@@ -307,7 +307,7 @@ namespace ChanSort.Api
}
}
private ChannelInfo FindChannel(ChannelList tvList, int subListIndex, ChannelInfo refChannel, Dictionary<long, List<ChannelInfo>> onidTsidSid)
private ChannelInfo FindChannel(ChannelList tvList, int subListIndex, ChannelInfo refChannel, Dictionary<long, List<ChannelInfo>> onidTsidSid, bool overwrite)
{
List<ChannelInfo> candidates;
@@ -349,12 +349,12 @@ namespace ChanSort.Api
// if the reference list has information about a service type (tv/radio/data), then only consider channels matching it (or lacking service type information)
var serviceType = refChannel.SignalSource & SignalSource.MaskTvRadioData;
if (serviceType != 0)
if (serviceType != 0 && serviceType != SignalSource.MaskTvRadioData)
{
channels = channels.Where(ch =>
{
var m = ch.SignalSource & SignalSource.MaskTvRadioData;
return m == 0 || m == serviceType;
return m == 0 || (m & serviceType) != 0;
}).ToList();
}

View File

@@ -8,7 +8,7 @@ namespace ChanSort.Api
{
private static readonly char[] Separators = { ';' };
private readonly ChannelList allChannels = new ChannelList(0, "All");
private readonly ChannelList allChannels = new ChannelList(SignalSource.All, "All");
#region ctor()
@@ -65,7 +65,7 @@ namespace ChanSort.Api
if (!int.TryParse(parts[0], out progNr))
continue;
var channel = new ChannelInfo(allChannels.SignalSource, lineNr, progNr, parts[1]);
var channel = new ChannelInfo(SignalSource.All, lineNr, progNr, parts[1]);
if (parts.Length >= 3)
{
var subParts = parts[2].Split('-');

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View File

@@ -48,16 +48,16 @@ left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
public string DvbServiceTable => "DigitalService";
public string SelectChannels => @"
select fi.ServiceListId, fi.ServiceId, fi.ChannelNumber, 1, 1, 0, 0, l.Lcn
select fi.ServiceListId, fi.ServiceId, fi.ChannelNumber, fi.ServiceItem3, fi.ServiceItem4, fi.ServiceItem6, fi.ServiceItem7, l.Lcn
from ServiceItem fi
left outer join Lcn l on l.ServiceId=fi.ServiceId and l.ServiceListId=fi.ServiceListId
";
public string ShortName => "Name";
public string ParentalLock => "0";
public string ShortName => "Service9";
public string ParentalLock => "0"; // supposedly "Service11", but that's not plausible
public string UpdateService =>
"update Service set Name=@name, Visible=@vis, Selectable=@sel where Pid=@servId";
public string UpdateChannelItem => "update ServiceItem set ChannelNumber=@ch /*, isDeleted=@del, Protected=@prot, Selectable=@sel, Visible=@vis */ where ServiceListId=@favId and ServiceId=@servId";
"update Service set Name=@name, Service9=@sname, Service11=@lock, Visible=@vis, /*Selectable=@sel,*/ Service16=@fav1, Service17=@fav2, Service18=@fav3, Service19=@fav4 where Pid=@servId";
public string UpdateChannelItem => "update ServiceItem set ChannelNumber=@ch, ServiceItem6=@del, ServiceItem7=@prot, ServiceItem3=@sel, ServiceItem4=@vis where ServiceListId=@favId and ServiceId=@servId";
public string DeleteChannelItem => "delete from ServiceItem where ServiceListId in (select Pid from ServiceList where name like 'FAV_')";
public string InsertChannelItem => "insert into ServiceItem (ServiceListId, ServiceId, ChannelNumber) values (@favId, @servId, @ch)";

View File

@@ -539,6 +539,9 @@ left outer join {dbSchema.DvbServiceTable} digs on digs.ServiceId=s.Pid
if (list.ReadOnly) // don't update read-only lists (i.e. containing LCNs)
continue;
if (list.IsMixedSourceFavoritesList)
continue;
// don't update the $all list directly. It will be updated while iterating all other lists
var favId = entry.Key;
if (favId == pidAll)

View File

@@ -7,13 +7,13 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Test.Loader.Hisense.ServicelistDb
{
[TestClass]
public class HisenseServicelistDbTest
public class HisenseServicelistDb2017Test
{
#region TestAstraChannelsAddedToCorrectLists
[TestMethod]
public void TestAstraChannelsAddedToCorrectLists()
{
this.TestChannelsAddedToCorrectLists("servicelist.db", "ASTRA1 19.2°E", 1214, 1052, 162);
this.TestChannelsAddedToCorrectLists("servicelist_2017.db", "ASTRA1 19.2°E", 1214, 1052, 162);
}
#endregion
@@ -21,7 +21,7 @@ namespace Test.Loader.Hisense.ServicelistDb
[TestMethod]
public void TesEutelsatChannelsAddedToCorrectLists()
{
this.TestChannelsAddedToCorrectLists("servicelist.db", "Hot Bird 13°E", 1732, 1439, 293);
this.TestChannelsAddedToCorrectLists("servicelist_2017.db", "Hot Bird 13°E", 1732, 1439, 293);
}
#endregion
@@ -51,7 +51,7 @@ namespace Test.Loader.Hisense.ServicelistDb
[TestMethod]
public void TestDeletingChannel()
{
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\servicelist.db");
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\servicelist_2017.db");
var plugin = new HisensePlugin();
var ser = plugin.CreateSerializer(tempFile);
ser.Load();
@@ -97,7 +97,7 @@ namespace Test.Loader.Hisense.ServicelistDb
[TestMethod]
public void TestChannelAndFavListEditing()
{
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\" + "servicelist.db");
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\" + "servicelist_2017.db");
RoundtripTest.TestChannelAndFavListEditing(tempFile, new HisensePlugin());
}
#endregion

View File

@@ -0,0 +1,102 @@
using System.Linq;
using System.Runtime.InteropServices;
using ChanSort.Api;
using ChanSort.Loader.Hisense;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Test.Loader.Hisense.ServicelistDb
{
[TestClass]
public class HisenseServicelistDb2021Test
{
#region TestAntennaChannelsAddedToCorrectLists
[TestMethod]
public void TestAntennaChannelsAddedToCorrectLists()
{
this.TestChannelsAddedToCorrectLists("servicelist_2021.db", "Antenna", 33, 24, 9);
}
#endregion
#region TestChannelsAddedToCorrectList
private void TestChannelsAddedToCorrectLists(string fileName, string listCaption, int expectedTotal, int expectedTv, int expectedRadio)
{
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\" + fileName);
var plugin = new HisensePlugin();
var ser = plugin.CreateSerializer(tempFile);
ser.Load();
var root = ser.DataRoot;
var list = root.ChannelLists.FirstOrDefault(l => l.Caption.StartsWith(listCaption));
Assert.IsNotNull(list);
Assert.AreEqual(expectedTotal, list.Channels.Count);
Assert.AreEqual(expectedTv, list.Channels.Count(ch => (ch.SignalSource & SignalSource.Tv) != 0));
Assert.AreEqual(expectedRadio, list.Channels.Count(ch => (ch.SignalSource & SignalSource.Radio) != 0));
// no data channels in Hisense/Loewe servicelist.db files
}
#endregion
#region TestDeletingChannel
[TestMethod]
public void TestDeletingChannel()
{
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\servicelist_2021.db");
var plugin = new HisensePlugin();
var ser = plugin.CreateSerializer(tempFile);
ser.Load();
var data = ser.DataRoot;
data.ValidateAfterLoad();
data.ApplyCurrentProgramNumbers();
// Pr# 804 = Das Erste HD
var dvbs = data.GetChannelList(SignalSource.DvbS);
var chan = dvbs.Channels.FirstOrDefault(ch => ch.Name == "Das Erste HD");
Assert.IsNotNull(chan);
Assert.AreEqual(804, chan.OldProgramNr);
Assert.AreEqual(804, chan.NewProgramNr);
Assert.IsFalse(chan.IsDeleted);
chan.NewProgramNr = -1;
data.AssignNumbersToUnsortedAndDeletedChannels(UnsortedChannelMode.Delete);
Assert.IsTrue(chan.IsDeleted);
Assert.IsTrue(chan.NewProgramNr > 0);
Assert.AreEqual(0, dvbs.Channels.Count(ch => ch.NewProgramNr <= 0));
foreach (var list in data.ChannelLists)
list.ReadOnly = false;
// save and reload
ser.Save(tempFile);
ser = plugin.CreateSerializer(tempFile);
ser.Load();
data = ser.DataRoot;
data.ValidateAfterLoad();
data.ApplyCurrentProgramNumbers();
// channel was marked deleted in database
dvbs = data.GetChannelList(SignalSource.DvbS);
chan = dvbs.Channels.FirstOrDefault(ch => ch.Name == "Das Erste HD");
Assert.IsNotNull(chan);
Assert.IsTrue(chan.IsDeleted);
Assert.AreEqual(-1, chan.NewProgramNr);
}
#endregion
#region TestChannelAndFavListEditing
[TestMethod]
public void TestChannelAndFavListEditing()
{
var tempFile = TestUtils.DeploymentItem("Test.Loader.Hisense\\ServicelistDb\\TestFiles\\" + "servicelist_2021.db");
RoundtripTest.TestChannelAndFavListEditing(tempFile, new HisensePlugin(), true, 271, 7);
}
#endregion
}
}

View File

@@ -239,13 +239,14 @@
<ItemGroup>
<Compile Include="ChannelDb\HisenseChannelDbTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServicelistDb\HisenseServicelistDbTest.cs" />
<Compile Include="ServicelistDb\HisenseServicelistDb2021Test.cs" />
<Compile Include="ServicelistDb\HisenseServicelistDb2017Test.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="ChannelDb\TestFiles\channel.db" />
<None Include="packages.config" />
<None Include="ServicelistDb\TestFiles\servicelist.db" />
<None Include="ServicelistDb\TestFiles\servicelist_2017.db" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">

View File

@@ -8,7 +8,7 @@ namespace Test.Loader
public static class RoundtripTest
{
#region TestChannelAndFavListEditing
public static void TestChannelAndFavListEditing(string tempFile, ISerializerPlugin plugin, bool swapChans = true, int firstProgNr = 1)
public static void TestChannelAndFavListEditing(string tempFile, ISerializerPlugin plugin, bool swapChans = true, int firstProgNr = 1, int firstProgIndex = 0)
{
var ser = plugin.CreateSerializer(tempFile);
ser.Load();
@@ -61,6 +61,9 @@ namespace Test.Loader
}
}
foreach (var l in root.ChannelLists)
l.ReadOnly = false;
ser.Save(tempFile);

View File

@@ -1,8 +1,9 @@
ChanSort Change Log
===================
TBA
- added experimental support for Hisense Vidaa U5.2 format
2021-07-08
- added experimental support for Hisense Vidaa U5.2 format (servicelist.db with different table and column names)
- applying a reference list did not work in some cases (depending on the type of reference list file and channel list)
2021-06-13
- improved High-DPI support

View File

@@ -6,7 +6,7 @@ cd /d %~dp0
set languages=cs de es hu pl pt ru tr
set curdate=%date:~6,4%-%date:~3,2%-%date:~0,2%
set target=%cd%\..\..\ChanSort_%curdate%
set DXversion=20.2
set DXversion=21.1
mkdir "%target%" 2>nul
rem del /s /q "%target%\*"
xcopy /idy debug\ChanSort.exe* "%target%"
@@ -98,11 +98,11 @@ goto:eof
:copyLangDll
set source="C:\Program Files (x86)\DevExpress %DXversion%\Components\Bin\Framework\%2\DevExpress.%1.v%DXversion%.resources.dll"
if exist %source% xcopy /idy %source% "%target%\%2"
set source="d:\downloads\DevExpress\DevExpressLocalizedResources_20%DXversion%_%2\DevExpress.%1.v%DXversion%.resources.dll"
set source="d:\downloads\DevExpress\20%DXversion%\DevExpressLocalizedResources_20%DXversion%_%2\DevExpress.%1.v%DXversion%.resources.dll"
if exist %source% xcopy /idy %source% "%target%\%2"
set source="C:\Program Files (x86)\DevExpress %DXversion%\Components\Bin\Framework\%2\DevExpress.%1.v%DXversion%.Core.resources.dll"
if exist %source% xcopy /idy %source% "%target%\%2"
set source="d:\downloads\DevExpress\DevExpressLocalizedResources_20%DXversion%_%2\DevExpress.%1.v%DXversion%.Core.resources.dll"
set source="d:\downloads\DevExpress\20%DXversion%\DevExpressLocalizedResources_20%DXversion%_%2\DevExpress.%1.v%DXversion%.Core.resources.dll"
if exist %source% xcopy /idy %source% "%target%\%2"
goto:eof