from typing import Optional
from typing import Tuple
import re


def _guess_show_num(episode_name: str) -> Optional[Tuple[int, int]]:
    """
    Guess the show number from the episode name.
    Supports:
        Exx-Eyy
        Exx
        YYYYY show_num ZZZZZZZZ ...
    Returns:
        (show_num_start, show_num_end) where show_num_end is equal show_num_start if only one show number is present.
        if no show number is present, returns None.
    """
    one_episode_regexp = re.compile(r"^E(?P<show_num_start>\d+)$")
    two_episode_regexp = re.compile(r"^E(?P<show_num_start>\d+)-E(?P<show_num_end>\d+)$")
    match = two_episode_regexp.match(episode_name)
    if match:
        return (
            int(match.group("show_num_start")),
            int(match.group("show_num_end")),
        )
    match = one_episode_regexp.match(episode_name)
    if match:
        return (int(match.group("show_num_start")), int(match.group("show_num_start")))
    try:
        show_num = int(episode_name.split(" ")[1])
        return (show_num, show_num)
    except (IndexError, ValueError):
        return None