Matching a TV guide to a channel list by hand always goes the same way. The big channels are easy. By channel 300 you're squinting at "UK: CHANNEL B +1 FHD" and wondering whether it's the "Channel B +1" in the guide or a regional version of it. By channel 2,000 you've stopped caring, and that's exactly when the mistakes creep in.
Then the provider renames half the list and you get to do it all again.
Why the names never match
A provider names channels for menus, not for machines. The same channel turns up as Channel B HD, UK: Channel B, CHANNEL B (UK) FHD and |UK| Channel B ᴴᴰ. Sometimes the country is at the front, sometimes at the end, and sometimes it only appears in the category.
A guide (the EPG) identifies channels differently. Most guides use the XMLTV format, where each channel has an ID such as channelb.uk and one or more display names, and every programme points at a channel by its ID. In an M3U playlist, the link between the two is each channel's tvg-id: it has to equal the guide's channel ID exactly, or players show no guide.
So before you can match anything, you have to clean up the provider's name and work out which country the channel belongs to. Only then can you look for the guide channel that's the same one.
The awkward ones
A few kinds of channel cause most of the trouble.
Local stations in the US
The network name is no help here. Each of the big networks has well over a hundred local affiliates, each with its own schedule for local news and sport. What identifies a station reliably is its call sign, usually four letters starting with K or W. If the provider's name contains one, match on it before anything else.
Timeshift channels
A "+1" channel shows the same programmes an hour later. Some guides list it as a channel of its own and some don't. If yours doesn't, the honest options are a guide that does, or the main channel's guide moved by an hour. What you shouldn't do is give a +1 the main channel's guide as it is, because then every single programme is an hour out.
Same name, different country
Plenty of channel names exist in several countries with nothing in common except the name. Match on the name alone, without the country, and sooner or later a viewer in one country is looking at another country's schedule.
Regional versions
Some channels run different programmes in different regions for part of the day. If the guide has the regions, pick the right one. If it doesn't, the national version is usually close enough, but it's worth knowing that it won't be exact.
A process that holds up
Whether you write the matching yourself or use a tool, the steps come out roughly the same.
- Clean the name. Strip quality tags (HD, FHD, 4K, ᴴᴰ), separators, country prefixes and extra spaces. Keep "+1" and numbers, because they change the meaning.
- Work out the country, from a prefix, a suffix, the category or the provider's grouping. If you can't, don't assign anything automatically.
- Try the strongest key first: a call sign for US locals, an exact display name for everything else.
- Score the rest. Compare the cleaned name against every display name in that country and keep the best few candidates with a score.
- Assign only the sure ones. Above a high score, assign it. Below that, show the top few and let a person click. Twenty clicks beat two hundred wrong guides.
- Remember the decision. When the provider renames a channel tomorrow, the match should survive, so store it against something that doesn't change with the name.
Easy mistakes
The most common one is assigning everything. A matcher that has to give every channel a guide will give some of them the wrong one, and wrong is worse than empty. A viewer with no guide knows there's no guide. A viewer with the wrong guide thinks the channel is wrong.
Time zones come next. XMLTV times carry an offset, like 20261115210000 +0000. If anything between the guide and the player drops that offset, every programme moves by however far the viewer is from UTC, and the gap changes by an hour when the clocks go forward or back.
The last one is size. A full guide for a few thousand channels is big, and every device downloads it. Guide files compress very well with gzip, often to a small fraction of their size, so make sure your server actually sends them compressed. Many don't by default.
In Minimus
We got tired of doing this by hand, so the guide matching in Minimus works much the same way. Guides for more than 28,000 channels in 239 countries come with it. Channels are matched by name and country, US locals by their call sign, the sure ones are assigned straight away and the rest come up as suggestions you accept with a click. There's a small demo of that screen on our home page if you want to try it.
If you're matching by hand today, start with steps one and two. Cleaning the names and pinning down the country gets you most of the way, whatever tool you use after that.