Created
May 29, 2022 02:46
-
-
Save pew/45c557268626347b27dfad2eef253741 to your computer and use it in GitHub Desktop.
upload to overcast with httpx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import httpx | |
| from bs4 import BeautifulSoup | |
| client = httpx.Client() | |
| r = client.post( | |
| "https://overcast.fm/login", | |
| data={ | |
| "email": "", | |
| "password": "", | |
| "then": "uploads", | |
| }, | |
| follow_redirects=True, | |
| ) | |
| output = r.content | |
| soup = BeautifulSoup(output, "html.parser") | |
| access_key = soup.select_one("input[name=AWSAccessKeyId]")["value"] | |
| policy = soup.select_one("input[name=policy]")["value"] | |
| signature = soup.select_one("input[name=signature]")["value"] | |
| key = soup.select_one("input[name=key]")["value"] | |
| filename = "podcast.mp3" | |
| key = key.replace("${filename}", filename) | |
| data = { | |
| "bucket": "uploads-overcast", | |
| "key": key, | |
| "AWSAccessKeyId": access_key, | |
| "acl": "authenticated-read", | |
| "policy": policy, | |
| "signature": signature, | |
| "Content-Type": "audio/mpeg", | |
| } | |
| files = {"file": (filename, open(filename, "rb"))} | |
| r = httpx.post("https://uploads-overcast.s3.amazonaws.com/", data=data, files=files) | |
| edata = { | |
| "key": key, | |
| } | |
| e = client.post( | |
| "https://overcast.fm/podcasts/upload_succeeded", data=edata, follow_redirects=True | |
| ) | |
| print(e.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment