MCPcopy Create free account
hub / github.com/CCSH/IPTV / sort_channel_data

Function sort_channel_data

main.py:328–343  ·  view source on GitHub ↗
(channel_data: list, chn_type: str, cfg_list: list)

Source from the content-addressed store, hash-verified

326 classifier.classify(channel_name, channel_address, new_line)
327
328def sort_channel_data(channel_data: list, chn_type: str, cfg_list: list) -> list:
329 if not channel_data:
330 return channel_data
331
332 if chn_type in ORDERED_CHANNEL_TYPES:
333 cfg_index_map = {cfg_name: idx for idx, cfg_name in enumerate(cfg_list)}
334 def _ordered_key(line):
335 name = line.split(',')[0] if ',' in line else ""
336 return cfg_index_map.get(name, len(cfg_list))
337 return sorted(channel_data, key=_ordered_key)
338 else:
339 def _dict_key(line):
340 name = line.split(',')[0] if ',' in line else ""
341 pure_name = re.sub(r'[^\w\u4e00-\u9fff]', '', name)
342 return pure_name if pure_name else name
343 return sorted(channel_data, key=_dict_key)
344
345def generate_live_text(classifier: ChannelClassifier, main_dict: dict) -> tuple[list, list]:
346 bj_time = datetime.now(timezone.utc) + timedelta(hours=8)

Callers 1

generate_live_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected