Downloading from Sproutvideo

Introduction

A semi-complicated guide on how to download videos from Sproutvideo.
While I say this guide works on Windows, Mac and Linux, I have only tried it on Linux.
In theory, as long as you do things correctly, it should work fine on Windows as well.

Keep in mind that this guide is written on July 19th, 2020.
If you're here months later, then I can't guarantee that this method still works, though I'll try to keep it updated.

Requirements

  • A computer (Windows, Mac, Linux). This doesn't work on iOS or Android.
  • The ability to Google for both guides and troubleshooting is helpful.
    • At least for installation of Git, Python and so on. I won't hold your hand there, as that's "out of scope" for this guide.
  • Familiarity with a CLI (Command Line Interface) is handy.
    • Basic understanding of PATH, directories etc. would help immensely.
  • Git - For downloading the Git repository from GitHub.
    • If you use some sort of package manager (Linux especially), you most likely can use that to install Git.
    • DigitalOcean has a nice community tutorial for installing Git that covers multiple platforms: Check it out here
  • Python
    • I've tested with both Python 3.8.4 and Python 2.7.17 and it seems to work with both.
      • Keep in mind that Python 3.x.x requires you to install pycryptodome.
      • See chapter 2a.
    • If you don't have either of those installed, get Python 3.8.x (whatever is the latest), as Python 2.7.x is no longer supported.
    • Linux: Ubuntu-based (Debian-based too?) distros often come with Python 2.7.x pre-installed, which should work.
    • Windows: Just use the "executable" installer. I recommend the 64-bit (x86-64) installer if you're on a 64-bit system.
  • FFmpeg
    • FFmpeg is used for video processing. I'm not entirely sure if this is necessary, but it probably is.
  • A userscript manager for your web browser, such as Violentmonkey, Tampermonkey, Greasemonkey etc.
    • Mainly used for installing a script that will display the "embed URL" that we need to use when downloading shit.
  • A Sproutvideo link (typically https://blah-blah.vids.io/videos/b6f0479ae87d244975439c6124592772/some-video-title).
    • It's from this page we'll be getting the "Embed URL".

Prerequisites

Your Browser's User Agent

Here's your browser's user agent, which we will use later.

Userscript

Once you have a userscript manager installed in your browser, visit this gist URL and click "Raw". Your userscript manager should prompt you to install the script.
The script is useful for displaying the "embed URL", which we will use to get the correct URL for download. It's possible to get this URL with other methods, but this makes it easier (especially if you're downloading multiple videos).

1. Getting the version of youtube-dl we need

You might be familiar with youtube-dl, which is an extremely powerful tool for downloading media from all kinds of different websites.
Unfortunately the version we need is a 'fork', because someone has started implementing support for Sproutvideo, but it hasn't been included in the main version yet.

All the credit for the Sproutvideo support should go to TheZ3ro on GitHub.

If you haven't installed Git yet, do so now.

  1. Open a Terminal/Command Prompt window.
  2. Create a directory, such as:
    • Windows: md C:\Projects
    • Linux/Mac: mkdir -p ~/projects
    • These directories are examples, but I'll be using them throughout the guide. If you don't know what you're doing, you should probably not change it from the examples.
  3. Navigate to the directory you just made:
    • Windows: cd C:\Projects
    • Linux/Mac: cd ~/projects
  4. "Clone" the youtube-dl Git repo from TheZ3ro's GitHub page:
    • git clone https://github.com/TheZ3ro/youtube-dl-1.git ytdl-sprout
    • Using the command above will clone it into a ytdl-sprout directory, which will automatically be created.
  5. Navigate into the Git repo's folder:
    • Windows/Linux/Mac: cd ytdl-sprout
  6. Checkout the correct Git branch:
    • Windows/Linux/Mac: git checkout sproutvideo

2. Testing if the project works (at all)

Before we move on, we need to make sure that both Python and our project works at all.
Python is absolutely necessary for youtube-dl to function, so let's test that first.

If you haven't installed Python at this point, do so now.
During Python installation, make sure that Add to PATH (or similar working) is checked/included (at least the Windows installer has this, see screenshot).
After Python installation, close and reopen your Terminal/Command Prompt windows and navigate back to the project folder (Windows: cd C:\Projects\ytdl-sprout or Linux/Mac: cd ~/projects/ytdl-sprout).
I highly recommend following a guide for installation for your operating system, unless you know what you're doing.

  1. Check that Python is working by running: python --version
    • It should output something like: Python 3.x.x or Python 2.x.x - nothing more.
  2. Check that the version of youtube-dl works by running: python youtube_dl/__main__.py --version
    • It should output a version number/date: 2020.xx.xx.
    • At the time of writing it's: 2020.03.24
  3. If neither of these gave you any weird error, we can assume they 'work' and move on.

2a. Installing pycryptodome

From my tests this seems to only be necessary on Python 3.x.
If you had to install Python 3.x, then please make sure to follow these instructions.

Without pycryptodome, you will eventually get an error that says:

ERROR: pycrypto not found. Please install it.

Keep in mind that we will be installing pycryptodome and NOT pycrypto. pycryptodome replaces pycrypto.

  1. Run python -m pip install pycryptodome
  2. If it installs without any errors, run the self-test to make sure it works correctly:
    • python -m Crypto.SelfTest
  3. The test should start and show a bunch of dots in your Terminal/Command Prompt. This will take a while, so just sit back and relax.
  4. Once it's complete, it should say something along the lines of: ``` Ran 39510 tests in 113.395s

OK ``` 5. If there were no errors during the self-test, then we can assume that it works correctly for our usage too.

3. Downloading a video from Sproutvideo

It's possible to download a list of videos in one command, but for testing purposes let's just test with one video.

  1. Visit the URL of the video you want to do download, typically looks like: https://blah-blah.vids.io/videos/b6f0479ae87d244975439c6124592772/some-video-title
  2. Type in the password to get to the page with the video player
  3. Page with the video player should look like this screenshot.
  4. Right-click on the 'Embed URL' and copy it to your clipboard.
  5. Now go back to your Terminal / Command Prompt and write the following command:
    • python youtube_dl/__main__.py --add-header "User-Agent: Your User Agent Here" "Embed URL Here"
    • <Your User Agent> should be replaced with your actual user agent (which you can get from the beginning of this page).
    • <Embed URL> should be replaced with the embed URL you just copied from the video player.
    • Full example: python youtube_dl/__main__.py --add-header "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" "https://videos.sproutvideo.com/embed/9c12db1a048ed3c5/b2060375b95276c1?type=hd"
  6. Run the command with the correct values replaced.
  7. If everything is working correctly, it should start downloading the video and eventually complete.

4. Downloading multiple videos (via text file)

Downloading multiple videos is not that much harder than downloading one video, but it is a bit more tedious, because you'll still have to get the "Embed URL" of each video.

  1. Create a text file using Notepad, call it something like sprout.txt. Save it as an empty text file for now.
    • Make sure to save it inside the ytdl-sprout folder.
  2. Get the "Embed URL" as explained in part 1-3 in chapter #3.
  3. Paste it into the sprout.txt text file using Notepad.
  4. Repeat this for all videos, but make sure to place each embed URL onto its own line.
  5. Once you've pasted all the embed URLs into the sprout.txt text file, make sure to save it.
  6. Run the following command to download all the URLs in the sprout.txt text file:
    • python youtube_dl/__main__.py --add-header "User-Agent: Your User Agent Here" -a sprout.txt
    • Note the -a before the sprout.txt filename.
    • Full example: python youtube_dl/__main__.py --add-header "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" -a sprout.txt
  7. The download should start. This will take a while, as it only downloads one video at a time.

5. Edge cases

5a. 403 Forbidden (Referer)

In some scenarios you may have videos that are give you a 403 Forbidden error. These might only play if they are 'embedded' on the correct page.
The easiest way to test if this is the case, open the embed URL in a new tab by copy/pasting (NOT clicking) and see if you get this error:

Screenshot of referer error

If you have an error like this, the easiest is to include another flag with your command:
--referer https://blah-blah-blah.vids.io/ - where the https://blah-blah-blah.vids.io/ is the original URL where you copied the embed URL from.

Full example with referer flag:

python youtube_dl/__main__.py --add-header "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" --referer "https://blah-blah-blah.vids.io/" "https://videos.sproutvideo.com/embed/9c12db1a048ed3c5/b2060375b95276c1?type=hd"

Usually it's not necessary to include the full URL and you can do it similar to my example.

5b. 403 Forbidden (User Agent)

There are other cases where you'd also get a 403 Forbidden error, where specifying a referer makes no difference.
Usually this is because the user agent, for whatever reason, has gotten banned.
The whole idea behind putting a custom user agent is to "blend in", as the 'download request' is supposed to look like a normal web browser streaming it.

While I don't recommend doing this permanently, a temporary fix for these kind of videos, would be to specify a custom user agent.
You can either decide to be creative about it, or try to blend it by spoofing a different web browser.
Here are a few examples:

  • --add-header "User-Agent: DontStopMeNow/1.0.0"
  • --add-header "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"
    • Firefox v78 on Ubuntu Linux
  • --add-header "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36"
    • Brave/Chrome v84 on Ubuntu Linux
  • --add-header "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0"
    • Firefox v78 on Windows

Finale

And that's it! If everything has been done correctly (and the project isn't broken), then you now have a setup for downloading videos from Sproutvideo.
As I mentioned in the Introduction, this works at the time of writing, but no guarantees that it will in the future.
I'll try my best to update this guide whenever necessary.