home

Downloading videos from SWITCHtube with yt-dlp

SWITCHtube, the educational video platform used in swiss universities, is not officially supported in yt-dlp - but lucky for us, the download still works thanks to the generic video extractor.

At the time of writing yt-dlp does not correctly identify the highest quality version of a video. To download the actual highest quality version of a video you have to use the format selector -f "wv*".

I recommend testing if this is still the case by also downloading the video with the default format selector and comparing the resolution / filesize

Download public videos

For public videos the download is as easy the following

$ yt-dlp -f "wv*" https://tube.switch.ch/videos/8a6ca2af

Download protected videos

For videos that require a login, you have to attach your session cookies. yt-dlp offers a very convenient feature to extract the cookies from your browser, if you pass the following argument:

$ # in this example the video is already public, so sending the cookies is not necessary in this case
$ # also i used the browser vivaldi, because thats the one i personally use, you will most likely have to change it
$ # to firefox, chrome, edge or safari
$ yt-dlp --cookies-from-browser vivaldi -f "wv*" https://tube.switch.ch/videos/8a6ca2af

Sending cookies as HTTP headers

If instead of yt-dlp you are using the original youtube-dl, which doesn’t offer to extract cookies from browsers, or if the cookie extraction doesn’t work for you, you will have to manually save them to a file with a browser extension as described in the youtube-dl docs, or you can edit the headers of HTTP requests.

To pass the cookie as an HTTP header follow these steps:

  1. Open the Network tab of the developer tools in your browser of choice
  2. Visit the SWITCHtube video page
  3. Inspect the initial request and look for the Cookie entry in the request headers

When you found the Cookie header entry, you can copy it and hand it to youtube-dl

$ # you can delete all entries except `authorization` from the cookie string (eg. `_saml_idp` or `_saml_sp`).
$ # again in this case the video is public, so this is not actually necessary
$ youtube-dl --add-header "Cookie:authorization=*****************************************" -f "wv*" https://tube.switch.ch/videos/8a6ca2af

Sidenote on video title extraction

At the time of writing there is a bug in the most recent release (yt-dlp 2022.10.04) which means that the filename will not actually match the title of the video, but instead be just the video ID.
I asked about this on the yt-dlp discord server and a fix was promptly made, but isn’t yet released.

The fix is now released in verion yt-dlp 2022.11.11