2021-09-19 23:32:38 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using ChanSort.Api;
|
2013-04-12 00:47:50 +02:00
|
|
|
|
|
|
|
|
|
|
namespace ChanSort.Loader.Panasonic
|
|
|
|
|
|
{
|
2021-01-23 14:22:18 +01:00
|
|
|
|
public class PanasonicPlugin : ISerializerPlugin
|
2013-04-12 00:47:50 +02:00
|
|
|
|
{
|
2017-10-28 13:20:39 +02:00
|
|
|
|
public string DllName { get; set; }
|
2021-09-19 23:32:38 +02:00
|
|
|
|
public string PluginName => "Panasonic (*.db, *.bin, *.xml)";
|
|
|
|
|
|
public string FileFilter => "*.db;*.bin;*.xml";
|
2021-01-23 14:22:18 +01:00
|
|
|
|
|
2013-04-12 00:47:50 +02:00
|
|
|
|
public SerializerBase CreateSerializer(string inputFile)
|
|
|
|
|
|
{
|
2022-10-01 19:51:14 +02:00
|
|
|
|
// check for files in the 2022 /mnt/vendor/tvdata/database/channel/ directory structure file format with tv.db and idtvChannel.bin
|
|
|
|
|
|
var name = Path.GetFileName(inputFile).ToLowerInvariant();
|
|
|
|
|
|
var baseDir = Path.GetDirectoryName(inputFile);
|
2023-06-01 11:11:33 +02:00
|
|
|
|
if (name == "hotel.bin")
|
|
|
|
|
|
baseDir = Path.Combine(baseDir, "mnt", "vendor", "tvdata", "database");
|
|
|
|
|
|
else if (name == "idtvchannel.bin")
|
|
|
|
|
|
baseDir = Path.GetDirectoryName(baseDir); // go down channel/database/tvdata/vendor/mnt
|
2022-10-05 18:03:12 +02:00
|
|
|
|
|
2023-06-01 11:11:33 +02:00
|
|
|
|
var tvDb = Path.Combine(baseDir, "tv.db");
|
|
|
|
|
|
if (File.Exists(tvDb) && File.Exists(Path.Combine(baseDir, "channel", "idtvChannel.bin")))
|
|
|
|
|
|
return new IdtvChannelSerializer(tvDb);
|
2022-10-01 19:51:14 +02:00
|
|
|
|
|
|
|
|
|
|
// Android based models use an .xml format. Unfortunately that format is utter garbage and not really useful
|
|
|
|
|
|
var ext = Path.GetExtension(inputFile).ToLowerInvariant();
|
|
|
|
|
|
if (ext == ".xml")
|
2021-09-19 23:32:38 +02:00
|
|
|
|
{
|
|
|
|
|
|
var data = File.ReadAllBytes(inputFile);
|
2024-02-25 17:59:34 +01:00
|
|
|
|
var header = Encoding.ASCII.GetBytes("<ChannelList>\n<ChannelInfo");
|
2021-09-19 23:32:38 +02:00
|
|
|
|
for (int i = 0; i < header.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (data[i] != header[i])
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new XmlSerializer(inputFile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-01 19:51:14 +02:00
|
|
|
|
// old svl.db / svl.bin formats
|
2022-11-29 18:21:52 +01:00
|
|
|
|
return new SvlSerializer(inputFile);
|
2013-04-12 00:47:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|