Skip to content

Commit

Permalink
IPTV HLS Add channels in ascending order
Browse files Browse the repository at this point in the history
Add the IPTV channels in ascending numerical channel number order.
In the QMap the order is based on channel number as string which
is not the same unless all channel numbers have the same number
of digits.

Refs #936
  • Loading branch information
kmdewaal committed Jan 1, 2025
1 parent f247a66 commit 6dad40f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,26 @@ void IPTVChannelFetcher::run(void)

if (!m_isMpts)
{
fbox_chan_map_t::const_iterator it = m_channels.cbegin();
for (uint i = 1; it != m_channels.cend(); ++it, ++i)
// Sort channels in ascending channel number order
std::vector<fbox_chan_map_t::const_iterator> acno (m_channels.size());
{
fbox_chan_map_t::const_iterator it = m_channels.cbegin();
for (uint i = 0; it != m_channels.cend(); ++it, ++i)
{
acno[i] = it;
}
std::sort(acno.begin(), acno.end(),
[] (fbox_chan_map_t::const_iterator s1, fbox_chan_map_t::const_iterator s2) -> bool
{
return s1.key().toInt() < s2.key().toInt();
}
);
}

// Insert channels in ascending channel number order
for (uint i = 0; i < acno.size(); ++i)
{
fbox_chan_map_t::const_iterator it = acno[i];
const QString& channum = it.key();
QString name = (*it).m_name;
QString xmltvid = (*it).m_xmltvid.isEmpty() ? "" : (*it).m_xmltvid;
Expand Down

0 comments on commit 6dad40f

Please sign in to comment.