import re


def timeleft_to_seconds(data):
    """Utility function that'll take a string of format NdNhNmNs and return a number of seconds."""
    if data.isdigit():
        return int(data)
    else:
        match = re.match('(?:(?P<days>\d+)d)?(?:(?P<hours>\d+)h)?(?:(?P<minutes>\d+)m)?(?:(?P<seconds>\d+)s)?', data)
        if match is None:
            return 0
        days = match.group('days') or 0
        hours = match.group('hours') or 0
        minutes = match.group('minutes') or 0
        seconds = match.group('seconds') or 0
        return int(days) * 86400 + int(hours) * 3600 + int(minutes) * 60 + int(seconds)