To create whitelist file with ABM SD/HD regions not using custom region without deleting HD channels to use IPTV insert.

I'm not expert so this may not be the best method to do it.

Code:
# Make treamrealy whitelist

def makeServiceRef(service):
	return "1:0:%X:%X:%X:%X:%X:0:0:0:" % (
		service["service_type"],
		service["service_id"],
		service["transport_stream_id"],
		service["original_network_id"],
		service["namespace"],
	)

TSIDs = [0x7D3, 0x7D7, 0x7D8, 0x7DB, 0x7DC, 0x7E0, 0x7E3, 0x7E4, 0x7E5, 0x7E7, 0x7E8, 0x7E9, 0x7EA, 0x7EB, 0x7EC, 0x7ED, 0x7EE, 0x7F0, 0x7F2, 0x82D, 0x838, 0x841, 0x842]
CHIDs = [0x44B, 0x48F, 0x490, 0x492, 0x4BA, 0x4C2, 0x4E2, 0x4F6, 0x551, 0xB00, 0xFC2, 0xFD2, 0xFD6, 0x177E]

changed = False

streamrelayrefs = [line.strip() for line in open('/etc/enigma2/whitelist_streamrelay', 'r').readlines()] if os.path.isfile('/etc/enigma2/whitelist_streamrelay') else []

for service in sorted(list(services[section_identifier]["video"].keys())):
	serv = services[section_identifier]["video"][service]
	if serv["transport_stream_id"] in TSIDs and ("free_ca" not in serv or serv["free_ca"] == 1) and (serv["service_type"] not in DvbScanner.HD_ALLOWED_TYPES or "channel_id" in serv and serv["channel_id"] in CHIDs):
		sref = makeServiceRef(serv)
		if sref not in streamrelayrefs:
			streamrelayrefs.append(sref)
			changed = True

if changed:
	streamrelayrefs.sort(key=lambda ref: (int((x:=ref.split(":"))[6], 16), int(x[5], 16), int(x[4], 16), int(x[3], 16)))
	open('/etc/enigma2/whitelist_streamrelay', 'w').write('\n'.join(streamrelayrefs))
	try:
		from Screens.InfoBarGenerics import reload_streamrelay
		reload_streamrelay()
	except:
		pass