Perl programmer for hire: download my resume (PDF).
John Bokma MexIT
freelance Perl programmer

Fixing subdl 1.0.2

Monday, March 15, 2010 | 1 comment

If you use the subdl command-line tool for downloading subtitles you probably have noticed that it suddenly stopped working a few days ago. Instead of a list of subtitle files to download I got the following output:

Searching for subtitles for moviehash=3816e450c974ca91...
Traceback (most recent call last):
  File "/home/john/.local-apps/subdl-1.0.2/subdl", line 374, in <module>
    main(sys.argv[1:])
  File "/home/john/.local-apps/subdl-1.0.2/subdl", line 350, in main
    search_results = SearchSubtitles(file, options.lang)
  File "/home/john/.local-apps/subdl-1.0.2/subdl", line 149, in SearchSubtitles
    data = results['data']
KeyError: 'data'

Since subdl is written in Python I opened subdl.py in Emacs and moved the point to line 149.

    try:
        results = xmlrpc_server.SearchSubtitles(osdb_token,searchlist)
    except Exception, e:
        raise SystemExit("Error in XMLRPC SearchSubtitles call: %s"%e)
    data = results['data']
    return data and [SubtitleSearchResult(d) for d in data]

Line 149 is the line which assigns to data the value for key 'data'. Since the traceback suggest that there is no such key, I added a print data before this assignment, which reported:

{'status': '301 Moved (http://api.opensubtitles.org/xml-rpc)'}

From this output I concluded that subdl tries to obtain data from a URL which no longer works but redirects to a new API URL instead (301, which means redirect permanently). The easiest fix is to update the API URL in the program to the new one. This URL is assigned to osdb_server at line 63 in version 1.0.2 of subdl.

So in order to fix subdl change

osdb_server = "http://www.opensubtitles.org/xml-rpc"

into

osdb_server = "http://api.opensubtitles.org/xml-rpc"

and the program should work again.

Related

Please post a comment | read 1 comment by Ludvik | RSS feed
AdSense: Goodbye and Good Riddance >
< Snow in Mexico