<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def upload_asciinema(filename):
    '''a wrapper around generation of an asciinema.api.Api to call the 
       upload command given an already existing asciinema file. 

       Parameters
       ==========
       filename: the asciinema file to upload, can be generated with 
                 function record_asciinema in record.py

    '''
    if os.path.exists(filename):

        import asciinema.config as aconfig
        from asciinema.api import Api

        # Load the API class

        cfg = aconfig.load()
        api = Api(cfg.api_url, os.environ.get("USER"), cfg.install_id)

        # Perform the upload, return the url

        uploader = UploadCommand(api, filename)
    
        try:
            url, warn = uploader.api.upload_asciicast(filename)
            if warn:
                uploader.print_warning(warn)

            # Extract just the url, if provided (always is https)
            if url:
                match = re.search('https://.+', url)
                if match: 
                    url = match.group() 
            return url

        except:
            bot.error('Problem with upload, skipping')

    else:
        bot.warning('Cannot find %s, skipping submission.' %filename)