import requests

from buzak_meme.meme import Meme

IMG_DELIMITER = "<img src=./graf/linux"


def get_random_meme() -> Meme:
    """Get a random meme from szkola.buz.info.pl"""
    res = requests.get("https://szkola.buz.info.pl")
    img_start = res.text.find(IMG_DELIMITER)
    meme_index = int(
        res.text[img_start + len(IMG_DELIMITER) :]
        .splitlines()[0]
        .replace(".jpg><br></aside>", "")
    )

    return Meme(meme_index)
