Script to Download TED Videos in Bulk

I recently became addicted to TED Videos. This inspired me to create a simple python script which helps one download TED Talks in bulk. Here is the main part of the script. Scroll down for download link and usage instructions.

#! /usr/bin/python

# Name: TED Video Downloader
# Version: 0.4
# Summary: A bulk TED Talks download tool
# License: BSD
# Author: Pranav Ashok
# Author-email:
# Author-homepage:
# Support:
# Support: Twitter (@pranavashok)

from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
import re
import os
import sys

f = open(sys.argv[1], 'r')
for link in f:
	web = urlopen(link)
	soup = BeautifulSoup(
	wholeTag = soup.find(href=re.compile(""))

	name = os.path.basename(link)
	fileName, fileExt = os.path.splitext(name)
	outputFile = fileName+".mp4"

	# wholeTag['href'] gives the value of the href attribute
	downloadUrl = wholeTag['href']

	w = open('', 'a')
	w.write('wget -c -O \"%s\" \"%s\"\n' % (outputFile, downloadUrl))

This script has used python library called BeautifulSoup for parsing HTML. If you are a developer, I'd recommend you to try BeautifulSoup. It's got a nice documentation and it's easy to use.
(Note: You don't need to download this, I've included it along with my script)

1. Download the TED Video Downloader
2. Extract the files to the directory where you want the videos to be downloaded.
3. Edit the toDownload.txt file and add the links of each TED Video in a new line (example links are already present).
4. Open a terminal and change to the directory where you extracted the files.
5. Execute 'sh'

$ sh

6. The python script will be executed automatically and download will start soon (depending on the length of your list)
7. If you want to stop the downloads, press Ctrl+C.
8. To resume a stopped/interrupted download, execute the following command in terminal - 'sh'

$ sh

9. Enjoy the videos!

I haven't implemented any sort of error handling. If the decides to change the format of their video page, this script might stop working. In that case, please drop a comment here and I'll fix it as soon as possible.

Hope you liked this script. Suggestions on optimization of the script are welcome.

Update (Dec 7, 2011): Changed due to changes in TED website structure.

Published by


I'm a student pursuing a masters degree in Theoretical Computer Science. Prior to this, I completed my bachelors in Computer Science and Engineering and worked for an year, until I realized that the slogging off at an office in front of the computer is not the job for me. I am easily fascinated and distracted by everything under the sun, which has kept me busy trying to figure out what I am going to. I love dreaming about making radical life decisions, bringing happiness on faces and about a world full of meadows and fluttery creatures and people who do not judge you for what you love doing.

13 thoughts on “Script to Download TED Videos in Bulk”

  1. Hello,
    I hope you can help me getting the script to work as I'm always getting this:

    Is-MacBook:Desktop V$ cd TED-Downloader-1Is-MacBook:TED-Downloader-1 V$ sh line 1: wget: command not found

  2. Hello Pranav,
    After to download theTED-Downloader.tar.bz2 I'm used
    tar -jxvf TED-Downloader.tar.bz2


    Traceback (most recent call last):
    File "", line 30, in
    downloadUrl = ""+wholeTag['href']
    TypeError: 'NoneType' object is unsubscriptable
    sh: File or directory not found

    Where are the script ?


Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>