Chris230291 / STB-Proxy

50 stars 32 forks source link

Channel sorting #33

Closed codeabilly closed 2 years ago

codeabilly commented 2 years ago

Can we get channel sorting feature, or at least an option to keep the channel order from original list.

Here's the deal. If I have source list like this:

#EXTM3U 
#EXTINF:-1 tvg-id="id-0000001" tvg-chno="0000001" group-title="GroupName",Channel B
#EXTINF:-1 tvg-id="id-0000002" tvg-chno="0000002" group-title="GroupName",Channel D
#EXTINF:-1 tvg-id="id-0000003" tvg-chno="0000003" group-title="GroupName",Channel A
#EXTINF:-1 tvg-id="id-0000004" tvg-chno="0000004" group-title="GroupName",Channel C

Once I run your proxy as a result this same list would give me end result like this:

#EXTM3U 
#EXTINF:-1 tvg-id="id-0000003" tvg-chno="0000003" group-title="GroupName",Channel A
#EXTINF:-1 tvg-id="id-0000001" tvg-chno="0000001" group-title="GroupName",Channel B
#EXTINF:-1 tvg-id="id-0000004" tvg-chno="0000004" group-title="GroupName",Channel C
#EXTINF:-1 tvg-id="id-0000002" tvg-chno="0000002" group-title="GroupName",Channel D

So instead of keeping list sorted by channel number, all of the sudden we're getting list sorted by channel name.

Why is that a problem you might ask, well if I'm getting a list from my provider that is sorted is some meaningful order like:

- language 1
  -- news channel A
  -- news channel B
  -- news ...

  -- movie channel A
  -- movie channel B
  -- movie ...

  -- sport channel A
  -- sport channel B
  -- sport ...
- language 2
  -- ...

this right here makes perfect sense (to me). However once you order those channels by name, all hell breaks loose. All of the sudden I have a list with all of the channel types mixed together without any meaningful order. In the end, I have to reorder list manually, no matter how good or bad the source list is. Which can be tiresome for bigger lists

In TiviMate (which I'm using) there is an option to sort channel within group by different parameters

I did try to manually update "enabled channels": [] prop within config.json + restart docker container, however that did not have any effect.

Other than that, great work with this repo. It's super easy to setup and most important works awesome. Keep up the good work :D

Chris230291 commented 2 years ago

The channels are already added in the order they appear in the list given by the getAllChannels response. Adding ordering options should be doable but I dont understand what ordering it is you want. By channel number? By genre?

EDIT: Sorry I do sort by name... I forgot. I can still add options to sort by other params though.

codeabilly commented 2 years ago

Thanks for quick response,

I didn't mean sorting options as a new feature. The issue I'm facing is that channels do not appear in the same order as they are in the source list.

So here's my workflow:

I was hoping this would effectively enable entire group to show without making any changes to the source group.

However when I'm looking at the playlist, I'm getting something like this:

Or if I'm looking at the rendered URL's that looks something like this:

So neither tvg-chno nor ID's in URL appears in order.

However, when I'm looking at http://<my.local.ip>/editor page and sort items by Number in interface, that does result with channels ordered same way as they appear in the original list, but it doesn't affect rendered list in any way.

My conclusion would be that some reordering does happen behind the scene which changes channel order from the source and I can't see the benefit of it.

ps. when I sort channels by Number in web interface, first enabled channel in that list has number 8418 but when I search for that number within config.json under enabled channels I'm not getting any results there. On the other hand when I look for it in rendered list I do find this:

#EXTINF:-1 tvg-id="<list.hash>" tvg-chno="8418" group-title="<group.title>",<channel.name>
http://<my.local.ip>/play/<list.hash>/131204

Now, this 131204 from url, that I can find within config.json.

In other words, I believe that rendering list ordered by tvg-chno="8418" attribute would result with channel order same as the source list. I believe that at this point sorting is done by channel name instead.

Chris230291 commented 2 years ago

Hi yes I understand. It is because at some point I thought it would be nice to sort the channels by name. I have added some options to allow sorting by genre, channel number, name or none at all (and they stack). The order in the edit page (or the config file) has no impact on how the channels are sorted. If no custom parameters are applied then it just uses the server provided value. This is why it is not in the config.

There are some other things I need to finish up before I will update the repo and docker image. I think it will solve your issue.

codeabilly commented 2 years ago

Great, glad I managed to explain it :D

I do agree some people might find sorting by name to be useful (to be honest I thought of it myself at some point), but that can become messy with bigger lists/groups. With that being said, I would prefer sorting to be removed or at least turned into an optional feature. As for default setup, I believe the order should be same as the source list.

For the time being, I will go with manual ordering within TiviMate to achieve what I want.

Again, great work with this project and I'll make sure to keep an eye on the future updates

Chris230291 commented 2 years ago

Just updated. If you are using Docker make sure you are not using the stable tag because I deleted it.

codeabilly commented 2 years ago

Awesome, works perfect. Thank you very much.