int? extractEpisodeNumberFromTitle(String title) {
  for (final p in _episodeTitlePatterns) {
    final m = p.firstMatch(title);
    if (m != null) {
      final n = int.tryParse(m.group(1)!);
      if (n != null) return n;
    }
  }
  return null;
}

final List<RegExp> _episodeTitlePatterns = [
  RegExp(r'第\s*0*(\d+)\s*[话集話]'),
  RegExp(r'\bS\d+E0*(\d+)\b', caseSensitive: false),
  RegExp(r'\bEP?\s*0*(\d+)\b', caseSensitive: false),
];
