Inconsistent category_ids
36-chambers opened this issue · 5 comments
Describe the bug
Every time the source refreshes the categories seem to be randomly sorted. For instance, when my source pulls it gets the following categories
- Sports Networks: 1
- Network TV: 2
- NHL: 3
When the source is pulled again (with cron) their ids are shuffled. This breaks my client because it expects the categories to be consistent. If the categories are shuffled while I'm using the app then when I select one category it will use the ID of that category to select streams and it will get incorrect data.
To Reproduce
Steps to reproduce the behavior:
- Pull source
- get_live_categories
- Pull source
- get_live_categories
- IDs are different every time
Expected behavior
I expect the category ids to be consistent every time. If it's possible I think using the upstream category ids would be ideal so that they are passed through and you can guarantee consistency. Otherwise it would be nice if I could at least map the category ids.
I have now implemented a fix which should preserve the category id, as long as there is no modification. If mapping or something occurs, the category_id is calculated.
Changes are in master branch.
Great thanks! How are the categories calculated?
If the title.matches the category it gets the provider id, if not the new category gets a new id based on a counter whit the initial value max(provider id)
@RohirrimRider I have implemented a new approach, pushed to master.
Seems to be resolved now