PredatH0r / ChanSort

TV channel list editor for Samsung, LG, Sony, Hisense, Panasonic, Philips, Sharp, Toshiba and MANY more.
842 stars 115 forks source link

add support for Xiaomi Mi TV (Android TV / mtkTv) #266

Open Mr-VIT opened 2 years ago

Mr-VIT commented 2 years ago

example backup channels.zip

PredatH0r commented 2 years ago

Does the TV create the "channels.zip" file directly or did you put the .bin, .bin.crc and .xml file in the zip for easier upload?

The content of the ".xml" is identical to what Panasonic's Android TVs export and can be opened in ChanSort already. You can drag&drop the ".xml"-File on ChanSort's title bar to open it (or use the File / Open channel list file menu).

You'll see something like this: image

This file format is so broken that I struggle to find the right words for it. Whoever programmed that export function in the TV's firmware clearly picked the wrong profession and has no idea of what he is doing.

The file barely contains any useful information. Channel names are truncated at 8 bytes (not characters!). In names with mixed latin and non-latin characters, the truncation can happen in the middle of a 2-byte character sequence, causing broken utf-8 characers and broken XML. Cyrillic characters need 2 bytes, so this 8-byte truncation means that Cyrillic channel names are only 4 characters long. They also write unescaped "&" characters to the file, which have special meaning in XML and must be written as \& correctly. I bet if a channel had a "\<" or ">" sign in the name, they would write that unescaped too and fail even harder. And if that is not bad enough, you can see that ChannelNumber=1 is assigned to more than one channel. It seems that this file mixes several lists from the TV (e.g. analog, cable, terrestrial, sat) without any indication of what is what. image

I haven't received any feedback yet if modifying a Panasonic .xml list actually works. I only received 1 sample file so far and that had only a single list inside (no duplicate numbers) and mostly latin characters (so typically 7-8 characters or channel names).

Panasonic also writes .bin and .bin.crc like your Xiamoi. I spent days researching, but unfortunately I have not found any way to read these files. The .bin is something similar to a ".zip", with several compressed data blocks inside, but not using any standardized format or algorithm. It's more or less encrypted the way it is. And the .crc does not use any known CRC algorithm or parameters. So even if I knew how to decompress/compress the .bin, it would be of no use if I can't calculate a new CRC after making changes.

Funny side note: Philips used the exact same .bin compression more than 10 years ago for their channel lists. It seems like a lot of brands buy hard- and firmware from the same OEM and just put different labels on the front.

masbaehr commented 2 years ago

Hi, im also interested in how you did create that ZIP file. I'm using a Xiaomi Mi TV 65" and would like to edit the channel list as the built-in editor is a PITA

Tachulin commented 1 year ago

Nothing new with this? Im also interested

Tachulin commented 1 year ago

Channel_list.zip

From my xiaomi mi tv q2 (50')

PredatH0r commented 1 year ago

Hi Tachulin. It looks like they fixed the broken data and finally write the full channel name to the .xml file. I do not know though if the TV actually processes the data in the .xml file when the list is imported back.

Can you confirm that your TV has "Das Erste HD" on program number 816 and "WDR 2 Ostwestfalen/Lippe" on 1 ?

If so, can you try to import the attached list? I swapped the two channels manually so that Das Erste HD should be on 1 and WDR 2 on 816.

Here is another modified version where I also set the "IsModified" value to 1

Please let me know if one of these 2 files worked for you.

EDIT: .zip files removed, will provide new ones shortly

Tachulin commented 1 year ago

Channel_list.zip

Hi Im now not at home. I will try today. But i can tell you now. i have no channel on number 1. All are on 8xx or 9xx

PredatH0r commented 1 year ago

Thanks for the info. Looks like the lower numbers are all radio channels. Since some TVs don't support mixing radio and TV numbers, here are two new files. I swapped 803 1-2-3.tv and 816 Das Erste HD so that the numbers should be reversed now. channel_list_mod1.zip channel_list_mod2.zip

Tachulin commented 1 year ago

Nice!! The second one works with "IsModified" value to 1 I also try to put the number that i want in the xml and also work.

To copy the files to a usb stick you first have to activate the developer mode (the same way like every android). Then you will have a menu "debug" on channels&inputs>channels with the option copy or load

PredatH0r commented 1 year ago

That's great news! So to confirm, you had to go to Settings / System / About / Android OS Build and click 7x "ok" to enable developer mode. Then you get a menu "Channels & Inputs / Channels / Debug / Copy" and "... / Load" ? That's new to me.

I came across a couple Android-TV lists, but they all had other means to export/import. There's also not a common export format for Android TVs. I guess it depends on the chip, board and TV manufacturer whatever software they add on top of Android. I might be wrong, but my understanding is that Android only covers the user interface and app infrastructure. The TV-tuning part is up to the manufacturer and its suppliers and so we end up with many different channel list file formats.

Tachulin commented 1 year ago

Sorry you are right.... I used to have it in another language (german). It is export and import. This menu only is show when you put a usb stick (not usb hard drive) and developer options are activate (7x click on "System>About>Android Tv OS build") 20230823_080715.jpg