From 66fe37b4ce5436dc1aeb105338713201b3cdde19 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 1 Jun 2008 15:15:14 +0200 Subject: [PATCH] add opensubtitles --- ox/opensubtitles.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ox/opensubtitles.py diff --git a/ox/opensubtitles.py b/ox/opensubtitles.py new file mode 100644 index 0000000..e7fca01 --- /dev/null +++ b/ox/opensubtitles.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=2:sts=2:ts=2 + +import re + +import feedparser +from oxutils.cache import getUrl, getUrlUnicode +import oxutils +from oxutils.lang import langCode2To3, langTo3Code + +def findSubtitlesByImdb(imdb, parts = 1, language = "eng"): + if len(language) == 2: + language = langCode2To3(language) + elif len(language) != 3: + language = langTo3Code(language) + url = "http://www.opensubtitles.org/en/search/" + if language: + url += "sublanguageid-%s/" % language + url += "subsumcd-%s/subformat-srt/imdbid-%s/rss_2_00" % (parts, imdb) + data = getUrl(url) + if "title>opensubtitles.com - search results