Help uploading MP3s via the LingQ API

I’ve been able to create text only uploads via a python script through the LingQ API as follows:

data = {"title" : "Lorem Ipsum",
             "text" : "Lorem ipsum dolor sit amet.",
             "tags" : ["Test"]
             }
    
     h = {'Authorization' : 'Token ' + API_KEY,
          'Content-Type' : 'application/json'}

     json_data = json.dumps(data)
    
     r = requests.post('https://www.lingq.com/api/v2/fi/lessons/', data=json_data, headers=h)
     print(r.text)

My current aim is to be able to upload a set of podcast mp3s for transcription. My research suggests this requires multipart encoding to send the mp3 file as well, but I can’t tell exactly what format the LingQ API backend accepts. I am following along previously working examples such as: Python - uploading audio via API - #5 by mescyn

Here’s my code:

    f = "foo.mp3"
    m = MultipartEncoder(fields={
        'title' : "Lorem Ipsum",
        'text' : "Lorem ipsum dolor sit amet.",
        'audio': (f, open(f, 'rb'), 'audio/mpeg')
        }
    )

    h = {'Authorization' : 'Token ' + API_KEY,
            'Content-Type' : m.content_type}
    
    req = requests.post('https://www.lingq.com/api/v2/fi/lessons/', 
                           headers=h, data=m)
    print(req.text)

This results in a 500 error:

<html>
	<head>
		<title>500 - Internal server error</title>
		<style type="text/css">
	        #bd #page #content-header {
	            display: none;
	        }
...

Would anyone be able to help give guidance on how to get mp3 uploads working?

Try this script by user rafarafa: https://github.com/daxida/lingq/blob/master/post/post.py