import re


def get_songs(description):
    """
    Extracts the songs located in the description
    :param BeautifulSoup description: video description as bs4 object
    :return list: song names
    """
    # pattern for a youtube video time (e.g. 34:87, 2:38:56)
    yt_time_regex = re.compile(r'(\d{1,2}:)?([0-5]?[0-9]):([0-5][0-9])')
    # "artist - song name" regex
    song_pattern = re.compile(
        r'[\w\s.()&\'!\-"\[\]]+\s?-\s?[\w\s.()&\'!\-"\[\]]+'
    )

    songs = []

    for idx, child in enumerate(description):
        if (child.string is not None
                and re.match(yt_time_regex, child.string)):

            # When there are no more children
            try:
                description[idx + 1]
            except IndexError:
                break

            # When the song name is located before the time
            if description[idx + 1].name == 'br':
                songs.append(description[idx - 1])
                continue

            # When the song name is located after the time
            songs.append(description[idx + 1])

    # If no songs were found, it might mean that the mix doesn't have
    # The times to go to certain songs in its description.
    # If that happens, the next block will perform
    # a similar search (with a song pattern)
    # but it's a bit less accurate.
    if not songs:
        songs = [child for child in description
                 if child.string is not None and
                 re.search(song_pattern, child.string)]

    return songs