From f85ff02a92a2654d5595b8b2f81bfb036094f10e Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Wed, 17 Feb 2021 09:41:06 +0100 Subject: [PATCH] - Panasonic: fixed error reading lists with channels that refer to non-existing transponders - Philips ChannelMap_45: incrementing fav list version number when saving and setting the last_watched_channel_id to the first channel in the fav list (ensuring that the channel is actually present in the list) --- source/ChanSort.Loader.Panasonic/DbChannel.cs | 9 ++++++--- source/ChanSort.Loader.Philips/BinarySerializer.cs | 8 ++++++-- source/changelog.md | 5 +++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/source/ChanSort.Loader.Panasonic/DbChannel.cs b/source/ChanSort.Loader.Panasonic/DbChannel.cs index bb7dc42..17cf98f 100644 --- a/source/ChanSort.Loader.Panasonic/DbChannel.cs +++ b/source/ChanSort.Loader.Panasonic/DbChannel.cs @@ -40,8 +40,11 @@ namespace ChanSort.Loader.Panasonic this.SignalSource |= SignalSource.SatIP; byte[] buffer = new byte[1000]; - var len = r.GetBytes(field["delivery"], 0, buffer, 0, 1000); - this.AddDebug(buffer, 0, (int) len); + if (!r.IsDBNull(field["delivery"])) + { + var len = r.GetBytes(field["delivery"], 0, buffer, 0, 1000); + this.AddDebug(buffer, 0, (int) len); + } this.Skip = r.GetInt32(field["skip"]) != 0; this.Encrypted = r.GetInt32(field["free_CA_mode"]) != 0; @@ -87,7 +90,7 @@ namespace ChanSort.Loader.Panasonic this.SignalSource |= LookupData.Instance.IsRadioTvOrData(stype); this.ServiceType = stype; - int freq = r.GetInt32(field["freq"]); + int freq = r.IsDBNull(field["freq"]) ? 0 : r.GetInt32(field["freq"]); if ((this.SignalSource & SignalSource.Sat) != 0) { // ReSharper disable PossibleLossOfFraction diff --git a/source/ChanSort.Loader.Philips/BinarySerializer.cs b/source/ChanSort.Loader.Philips/BinarySerializer.cs index 5637429..fd194fd 100644 --- a/source/ChanSort.Loader.Philips/BinarySerializer.cs +++ b/source/ChanSort.Loader.Philips/BinarySerializer.cs @@ -1005,14 +1005,14 @@ namespace ChanSort.Loader.Philips { cmd.CommandText = $"delete from FavoriteChannels where fav_list_id={favListId}"; cmd.ExecuteNonQuery(); - sqlInsertOrUpdateList = "update List set list_name=@name where list_id=@id"; + sqlInsertOrUpdateList = "update List set list_name=@name, list_version=list_version+1 where list_id=@id"; } else { favListId = favListIndexToId.Count == 0 ? 1 : favListIndexToId.Max() + 1; favListIndexToId[favListIndex] = favListId; favListIdToIndex[favListId] = favListIndex; - sqlInsertOrUpdateList = "insert into List (list_id, list_name) values (@id,@name)"; + sqlInsertOrUpdateList = "insert into List (list_id, list_name, list_version) values (@id,@name,1)"; } cmd.CommandText = sqlInsertOrUpdateList; @@ -1048,6 +1048,10 @@ namespace ChanSort.Loader.Philips cmd.CommandText = "delete from List where list_id not in (select fav_list_id from FavoriteChannels)"; cmd.ExecuteNonQuery(); + // make sure the last_watched_channel_id is valid in the list + cmd.CommandText = "update List set last_watched_channel_id=(select min(channel_id) from FavoriteChannels f where f.fav_list_id=List.list_id)"; + cmd.ExecuteNonQuery(); + trans.Commit(); conn.Close(); } diff --git a/source/changelog.md b/source/changelog.md index 2a75dcc..a188cb3 100644 --- a/source/changelog.md +++ b/source/changelog.md @@ -1,6 +1,11 @@ ChanSort Change Log =================== +2021-02-17 +- Panasonic: fixed error reading lists with channels that refer to non-existing transponders +- Philips ChannelMap_45: incrementing fav list version number when saving and setting the last_watched_channel_id to + the first channel in the fav list (ensuring that the channel is actually present in the list) + 2021-02-09 - Sony: fixed incorrect checksum error for Android based TVs which use CR+LF as line separators (normally only LF is used) - Philips: show info that it may be necessary to unplug and reboot the TV after the import