Upload URL (Not File) to Overcast

There's a chance that this is beyond the range of this forum, and if it is I apologize. However I think there is a chance that someone more familiar with shell scripting than me may have an idea.

When browsing the web on my Mac, I often find links to pages with audio files that I want to quickly add to Overcast, my podcast player of choice. My main method so far has been to download them and upload them to Overcast with another macro.

Recently, a feature was introduced for Overcast Premium members. By logging into the Overcast website, you can submit an URL that points to an audio file. The audio will be immediately added to Overcast. I tried for a long time to script this.

Overcast-upload-URL

In a perfect world, I could be on the audio file’s web page and use a Keyboard Maestro macro to:

  1. Get the current URL in Chrome.
  2. Call a script with the URL as input which…
  3. Sends the URL directly to Overcast, which downloads the audio.

Here is a script (slightly modified from this) that takes audio files as input and uploads them to any Overcast account.

#!/usr/bin/env bash

if [[ -z "$1" ]]
then
  echo "Please enter a file to upload."
  exit 1
fi

if [[ ! -f $1 ]]
then
  echo "File $1 not found."
  exit 1
fi

overcast_email=email@example.com
overcast_password=password123

if [[ -z "$overcast_email" ]] \
  || [[ -z "$overcast_password" ]]
then
  echo "Please set your credentials in ~/.overcast_auth like this:"
  echo ""
  echo 'export overcast_email="yourEmail@example.com"'
  echo 'export overcast_password="yourPassword"'
  echo ""
  exit 1
fi

echo "Logging in as $overcast_email"
curl -Ls  --compressed \
  -d "then=uploads" \
  -d "email=$overcast_email" \
  -d "password=$overcast_password" \
  -c overcast_cookies \
  -o upload.tmp \
  https://overcast.fm/login \
  || exit 1

policy=$(grep -o -E \
  '<input type="hidden" id="upload_policy" name="policy" value="[^\\"]+' \
  upload.tmp \
  | sed \
  's/<input type="hidden" id="upload_policy" name="policy" value="//g' \
  )

signature=$(grep -o -E \
  '<input type="hidden" id="upload_signature" name="signature" value="[^\\"]+' \
  upload.tmp \
  | sed \
  's/<input type="hidden" id="upload_signature" name="signature" value="//g' \
  )

AWSAccessKeyId=$(grep -o -E \
  '<input type="hidden" name="AWSAccessKeyId" value="[^\\"]+' \
  upload.tmp \
  | sed \
  's/<input type="hidden" name="AWSAccessKeyId" value="//g' \
  )

key=$(grep -o -E \
  'data-key-prefix="[^\\"]+' \
  upload.tmp \
  | sed \
  's/data-key-prefix="//g' \
  )

filename=$(basename $1)

if [[ -z "$policy" ]] \
  || [[ -z "$signature" ]] \
  || [[ -z "$AWSAccessKeyId" ]] \
  || [[ -z "$key" ]] \
  || [[ -z "$filename" ]]
then
  echo "There was a problem fetching the upload page."
  echo "Make sure your email and password are correct."
  exit 1
fi

rm upload.tmp

echo Uploading $filename
curl -Ls --compressed \
  -F "bucket=uploads-overcast" \
  -F "key=$key$filename" \
  -F "AWSAccessKeyId=$AWSAccessKeyId" \
  -F "acl=authenticated-read" \
  -F "policy=$policy" \
  -F "signature=$signature" \
  -F "Content-Type=application/x-www-form-urlencoded" \
  -F "file=@$1" \
  -b overcast_cookies \
  https://uploads-overcast.s3.amazonaws.com/ \
  || exit 1

curl -Ls --compressed \
  -F "key=$key$filename" \
  -b overcast_cookies \
  https://overcast.fm/podcasts/upload_succeeded \
  > /dev/null \
  || exit 1

rm overcast_cookies

echo Done!

I have tried many different ideas to modify this script to accept URLs instead of audio files. I have tried changing the content type of the request to "application/x-www-form-urlencoded" and encoding the URL but this has not worked.

I know I'm on the right track because I will successfully upload blank audio tracks to Overcast, with the same title as the URL I tried to upload. Of course, this is very different than actually uploading the audio of that same URL.

This has to be possible somehow.

I don't know the answer, but I suspect your best chance of getting this to work is to get support added to cloudyuploader which can already upload from the command line to Overcast.

I suspect / hope that if the developer of that tool looked into it, he would be able to add it without "too much" trouble, but IANADeveloper, so I have no idea, it's mostly just wishing and hoping.

I did open Issue #9 on GitHub requesting this feature, which I'd been meaning to do anyway. You could add your voice/+1 to it if you wanted to signal that others would find this useful.

I was hesitant to ask Andrew directly, but if two people want it, perhaps there is a chance he could look into it! We'll see.

Side note: On Automators you were the one who introduced me to cloudyuploader to begin with, which I was quite glad to hear about. It saved me from my clunky UI scripting that tried to open the browser and only worked half the time. Now it's an indispensable tool and I am incredibly grateful to Andrew for writing it.

1 Like

Oh! Ha! That's funny. It's a small 'net after all…

I had tried writing my own script, which was so so so far from working it isn't even funny, so I'm extremely grateful for this as an alternative.