def parse_track_names(track_section): templates = extract_tracklist_templates(track_section.text) all_titles = [] for template in templates: template_entries = split_tracklist(template) titles = [] for entry in template_entries: label,value = split_tracklist_entry(entry) if is_title_entry(label): link,text = extract_link(value.strip()) titles.append(text if text else link) all_titles.extend(titles) return all_titles
def parse_tracklist_section(track_section): templates = extract_tracklist_templates(track_section.text) if templates: return parse_tracklist_templates(templates) else: return parse_track_names(track_section)