Skip to content

Commit

Permalink
- added Italian translation
Browse files Browse the repository at this point in the history
- updated Polish translation
- added support for a Hisense HIS_SVL variant with different file structure
- Samsung IP-TV lists allow editing stream and logo URLs
  • Loading branch information
PredatH0r committed Aug 14, 2023
1 parent e561f71 commit 3ed2e28
Show file tree
Hide file tree
Showing 52 changed files with 3,337 additions and 513 deletions.
2 changes: 1 addition & 1 deletion source/ChanSort.Api/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions source/ChanSort.Api/Resources.it.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ChannelList_ProgramNrAssignedToMultipleChannels" xml:space="preserve">
<value>{0} Il programma #{1} è assegnato a più canali: indice {2}='{3}' e indice {4}='{5}'</value>
</data>
<data name="ChannelList_AddChannel__DuplicateUid" xml:space="preserve">
<value>{0}: il canale '{1}' ha più record di dati: indice {2}=Pr#{3} e indice {4}=Pr#{5}</value>
</data>
</root>
42 changes: 36 additions & 6 deletions source/ChanSort.Loader.Hisense/ChanSort.Loader.Hisense.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
; HIS_SVL.BIN, HIS_TSL.BIN and HIS_FAV.BIN
; ========================================

; there are several versions of this format, with no deterministic way to detect the format
; ChanSort checks if the file sizes are multiples of the record sizes to guesstimate the version

[Header]
RecordSize=40
ID=0
Expand All @@ -12,16 +15,20 @@ BlockSize=36
[Version1]
TSL_Record=304
SVL_Record=264
FAV_Header=24
FAV_Record=80
ReadDvb=false

[Version2]
TSL_Record=328
SVL_Record=304
FAV_Header=16
FAV_Record=80
ReadDvb=true

;=== variant with 304 byte TSL record and 264 bytes SVL record (LTDN55K390XWSEU3D V00.01.00a.E0430)

[TSL_Record:304]
[TSL_Record:Version1]
RecordSize=304
ID=0
BroadcastType=2
Expand All @@ -34,7 +41,7 @@ DvbsSymbolRate=28
Name=188
NameSize=28

[SVL_Record:264]
[SVL_Record:Version1]
RecordSize=264

RecordId=0
Expand Down Expand Up @@ -79,10 +86,26 @@ NameSize=16

BroadcastSystemData=48

[FAV_Header:Version1]
RecordSize=24
CountFav1=16
CountFav2=18
CountFav3=20
CountFav4=22

[FAV_Record:Version1]
RecordSize=80
SvlTableId=0
SvlRecordId=2
DisplayNumber=4
DisplayNumberSize=10
ChannelName=15
ChannelNameSize=64


;=== variant with 328 byte TSL record and 304 bytes SVL record

[TSL_Record:328]
[TSL_Record:Version2]
RecordSize=328
ID=0
BroadcastType=2
Expand All @@ -96,7 +119,7 @@ DvbsSymbolRate=28
Name=216
NameSize=32

[SVL_Record:304]
[SVL_Record:Version2]
RecordSize=304

RecordId=0
Expand Down Expand Up @@ -141,7 +164,7 @@ NameSize=96

BroadcastSystemData=136

[DVB_Data]
[DVB_Data:Version2]
ShortName=4
ShortNameSize=16
LinkageMask=28
Expand All @@ -154,7 +177,14 @@ DvbcTsid=118
DvbcOnid=120
ServiceType=129

[FAV_Record]
[FAV_Header:Version2]
RecordSize=16
SizeFav1=0
SizeFav2=4
SizeFav3=8
SizeFav4=12

[FAV_Record:Version2]
RecordSize=80
SvlTableId=0
SvlRecordId=2
Expand Down
68 changes: 42 additions & 26 deletions source/ChanSort.Loader.Hisense/HisBin/HisSvlBinSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace ChanSort.Loader.Hisense.HisBin;
*
* This binary format is based on a customized MediaTek format, which means that there may be many incompatible
* variants that can't be identified and distinguished easily.
* This loader only supports the known HiSense variants with 264 and 304 bytes per channel in HIS_SVL.BIN.
* This loader supports 2 known versions with 264 and 304 bytes per channel in HIS_SVL.BIN, which also differ in TSL and FAV file layouts
*
* See also the his-svl.h file in Information/FileStructures_for_HHD_Hex_Editor_Neo
*
Expand All @@ -32,6 +32,7 @@ public class HisSvlBinSerializer : SerializerBase
private string favFileName;
private byte[] svlFileContent;
private byte[] tslFileContent;
private byte[] favFileContent;
private const int MaxFileSize = 4 << 20; // 4 MB

private bool readDvbData;
Expand All @@ -42,7 +43,7 @@ public class HisSvlBinSerializer : SerializerBase
private const string ERR_badFileFormat = "The content of the file doesn't match the expected format.";

private IniFile ini;
private DataMapping headerMapping, svlMapping, tslMapping, dvbMapping, favMapping;
private DataMapping headerMapping, svlMapping, tslMapping, dvbMapping, favHeaderMapping, favMapping;
private readonly Dictionary<int, Transponder> transponder = new ();

#region ctor()
Expand Down Expand Up @@ -82,10 +83,6 @@ private void ReadConfigurationFromIniFile()
this.ini = new IniFile(iniFile);
this.headerMapping = new DataMapping(ini.GetSection("Header"));
this.headerRecordSize = headerMapping.Settings.GetInt("RecordSize");

this.dvbMapping = new DataMapping(ini.GetSection("DVB_Data"));
this.dvbMapping.DefaultEncoding = this.DefaultEncoding;
this.favMapping = new DataMapping(ini.GetSection("FAV_Record"));
}
#endregion

Expand Down Expand Up @@ -115,6 +112,7 @@ private void DetectFormatVersionFromContent(string tslName)
{
var svlLen = new FileInfo(this.FileName).Length;
var tslLen = new FileInfo(tslName).Length;
var favLen = new FileInfo(this.favFileName).Length;
IniFile.Section candidate = null;
foreach (var section in this.ini.Sections)
{
Expand All @@ -124,22 +122,29 @@ private void DetectFormatVersionFromContent(string tslName)
continue;
if ((svlLen - this.headerRecordSize * 3) % section.GetInt("SVL_Record") != 0)
continue;
if (favLen != 0 && (favLen - section.GetInt("FAV_Header")) % section.GetInt("FAV_Record") != 0)
continue;
if (candidate != null)
throw LoaderException.Fail("Unable to uniquely infer file format from its content");
candidate = section;
}

if (candidate == null)
throw LoaderException.Fail("File content doesn't match any known SVL/TSL/FAV.bin data format versions");
throw LoaderException.Fail("File content doesn't match any known SVL/TSL/FAV.bin format versions");

var tslRecordSize = candidate.GetInt("TSL_Record");
this.svlRecordSize = candidate.GetInt("SVL_Record");
this.readDvbData = candidate.GetBool("ReadDvb");

this.svlMapping = new DataMapping(ini.GetSection("SVL_Record:" + this.svlRecordSize));
this.svlMapping.DefaultEncoding = this.DefaultEncoding;
this.tslMapping = new DataMapping(ini.GetSection("TSL_Record:" + tslRecordSize));
this.tslMapping = new DataMapping(ini.GetSection("TSL_Record:" + candidate.Name));
this.tslMapping.DefaultEncoding = this.DefaultEncoding;
this.svlMapping = new DataMapping(ini.GetSection("SVL_Record:" + candidate.Name));
this.svlMapping.DefaultEncoding = this.DefaultEncoding;
this.dvbMapping = new DataMapping(ini.GetSection("DVB_Data:" + candidate.Name));
this.dvbMapping.DefaultEncoding = this.DefaultEncoding;
this.favHeaderMapping = new DataMapping(ini.GetSection("FAV_Header:" + candidate.Name));
this.favHeaderMapping.DefaultEncoding = this.DefaultEncoding;
this.favMapping = new DataMapping(ini.GetSection("FAV_Record:" + candidate.Name));
this.favMapping.DefaultEncoding = this.DefaultEncoding;
}
#endregion

Expand Down Expand Up @@ -389,17 +394,29 @@ private void LoadFavFile(string filename)
{
if (!File.Exists(filename))
return;
var content = File.ReadAllBytes(filename);
var favListSizes = new int[4];
for (int i = 0; i < 4; i++)
favListSizes[i] = BitConverter.ToInt32(content, i * 4);
var content = this.favFileContent = File.ReadAllBytes(filename);

int[] favCount = new int[4];
var recSize = favMapping.Settings.GetInt("RecordSize");
favHeaderMapping.SetDataPtr(content, 0);
if (favHeaderMapping.Settings.GetInt("SizeFav1", -1) >= 0)
{
for (int i = 0; i < 4; i++)
favCount[i] = BitConverter.ToInt32(content, i * 4) / recSize;
}
else if (favHeaderMapping.Settings.GetInt("CountFav1", -1) >= 0)
{
for (int i = 0; i < 4; i++)
favCount[i] = favHeaderMapping.GetWord("CountFav" + (i+1));
}
else
return;

var dispNumLen = favMapping.Settings.GetInt("DisplayNumberSize");
favMapping.SetDataPtr(content, 16 - recSize);
favMapping.SetDataPtr(content, favHeaderMapping.Settings.GetInt("RecordSize") - recSize);
for (int i = 0; i < 4; i++)
{
for (int j = 0, c = favListSizes[i] / recSize; j < c; j++)
for (int j = 0, c = favCount[i]; j < c; j++)
{
favMapping.BaseOffset += recSize;

Expand Down Expand Up @@ -525,8 +542,7 @@ private byte[] GetNewFavContent()
using var mem = new MemoryStream();
using var writer = new BinaryWriter(mem);

for (int i=0; i<4; i++)
writer.Write(0);
writer.Write(this.favFileContent, 0, this.favHeaderMapping.Settings.GetInt("RecordSize"));

var favRecordSize = favMapping.Settings.GetInt("RecordSize");
var tmp = new byte[favRecordSize];
Expand All @@ -552,12 +568,11 @@ private byte[] GetNewFavContent()
}

// update header
writer.Flush();
var off = mem.Position;
mem.Seek((i-1) * 4, SeekOrigin.Begin);
writer.Write(order.Count * favRecordSize);
writer.Flush();
mem.Seek(off, SeekOrigin.Begin);
favHeaderMapping.SetDataPtr(mem.GetBuffer(), 0); // the MemStream buffer gets reallocated while adding data
if (favHeaderMapping.Settings.Keys.Contains("SizeFav1"))
favHeaderMapping.SetDword("SizeFav" + i, order.Count * favRecordSize);
else if (favHeaderMapping.Settings.Keys.Contains("CountFav1"))
favHeaderMapping.SetWord("CountFav" + i, order.Count);
}

tmp = new byte[mem.Length];
Expand Down Expand Up @@ -589,11 +604,12 @@ public override Encoding DefaultEncoding
return;
base.DefaultEncoding = value;

this.dvbMapping.DefaultEncoding = value;
if (this.svlMapping != null)
{
this.svlMapping.DefaultEncoding = value;
this.tslMapping.DefaultEncoding = value;
this.dvbMapping.DefaultEncoding = value;
this.favMapping.DefaultEncoding = value;
this.ReparseNames();
}
}
Expand Down
Loading

0 comments on commit 3ed2e28

Please sign in to comment.