def get_terminal_size(fallback=(80, 24)):
    # Attempt to use the environment first
    try:
        columns = int(os.environ["COLUMNS"])
    except (KeyError, ValueError):
        columns = 0

    try:
        lines = int(os.environ["LINES"])
    except (KeyError, ValueError):
        lines = 0

    # Only query if necessary
    if columns <= 0 or lines <= 0:
        try:
            columns, lines = _get_terminal_size(sys.__stdout__.fileno())
        except (NameError, OSError):
            pass

    # Use fallback as last resort
    if columns <= 0 and lines <= 0:
        columns, lines = fallback

    return terminal_size(columns, lines)
Get the best matching show id for `series`, `year` and `country_code`.
dataset/ETHPy150Open chrippa/livestreamer/src/livestreamer_cli/packages/shutil_backport.py/get_terminal_size--crossover with--dataset/ETHPy150Open Diaoul/subliminal/subliminal/providers/addic7ed.py/Addic7edProvider.get_show_id