Ubuntu – youtube-dl stopped working

videoyoutubeyoutube-dl

On my 12.04 LTS I can't download from YouTube via youtube-dl. I used to do that, but recently (for a week) I'm not able. I tried on many videos and I get same output:

$ youtube-dl -t http://www.youtube.com/watch?v=Sh0ciyuXbJA
[youtube] Setting language
[youtube] Sh0ciyuXbJA: Downloading video webpage
[youtube] Sh0ciyuXbJA: Downloading video info webpage
[youtube] Sh0ciyuXbJA: Extracting video information
Traceback (most recent call last):
  File "/usr/bin/youtube-dl", line 4645, in <module>
    main()
  File "/usr/bin/youtube-dl", line 4636, in main
    _real_main()
  File "/usr/bin/youtube-dl", line 4620, in _real_main
    retcode = fd.download(all_urls)
  File "/usr/bin/youtube-dl", line 869, in download
    ie.extract(url)
  File "/usr/bin/youtube-dl", line 1135, in extract
    return self._real_extract(url)
  File "/usr/bin/youtube-dl", line 1406, in _real_extract
    url_map = dict((ud['itag'][0], ud['url'][0] + '&signature=' + ud['sig'][0]) for ud in url_data)
  File "/usr/bin/youtube-dl", line 1406, in <genexpr>
    url_map = dict((ud['itag'][0], ud['url'][0] + '&signature=' + ud['sig'][0]) for ud in url_data)
KeyError: 'sig'

It seems it's some signature problem. I still can download videos via vlc. But I like youtube-dl – its faster.
I did already:

sudo apt-get --purge remove youtube-dl
sudo apt-get install youtube-dl
sudo youtube-dl --update

…but it didn't help.

Best Answer

Youtube updates his anti-download security system quite offen. You should keep your youtube-dl up-to-date. The version Ubuntu 12.04 Precis installs by default is 2012.02.27 (two years old).

You can subscribe to the WebUpd8 PPA to get new releases when they're out (that is once or twice a week) :

sudo add-apt-repository ppa:nilarimogard/webupd8 -y
sudo apt-get update
sudo apt-get dist-upgrade

You'll also find the .deb package of the latest youtube-dl release on that PPA (here and search for youtube-dl). Install it with a GUI-tool like gdebi or Ubuntu Software Center, or with these command lines :

cd directory/where/you/downloaded/the/package
dpkg -i youtube-dl*
sudo apt-get install -f