Using ThankView API to download videos


At the end of last year, my school used ThankView to record surprise videos for each graduating senior. We had 2-4 teachers record a short video reflecting on their relationship with the student and wishing them well. As I prepare to leave that job, I wanted to make sure the school had an archive of those videos outside of the ThankView website. I couldn’t figure out a good way to download all of the videos within the product (aside from one at a time). Lucikly, their API allows you to bulk download videos.

Here is the code I used to download all the videos into a directory called thankview:

import http.client
import urllib.request
import mimetypes
import json

conn = http.client.HTTPSConnection("api.thankview.com")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer *********'
}

for page in range(6):
  uri = "/api/video?limit=100&page=" + str(page)
  conn.request("GET", uri, payload, headers)
  res = conn.getresponse()
  data = res.read()
  conn.close()
  jsonResponse = json.loads(data)
  videos = jsonResponse["data"]["videos"]
  
  for video in videos:
    print("id: ", video["id"])
    print("title: ", video["title"])
    print("video_path: ", video["video_path"])
    filename = "thankview/" + str(video["id"]) + "-" + video["title"] + ".mp4"
    print(filename)
    try:
      urllib.request.urlretrieve(video["video_path"],filename)
    except:
      print("error")

Leave a Reply

Your email address will not be published. Required fields are marked *