From afe518fc7d249c7f4c1fc7283fcc78e7180bb7a6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 11 Aug 2007 15:47:43 +0000 Subject: [PATCH] sort subtitle parts --- scrapeit/opensubtitles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scrapeit/opensubtitles.py b/scrapeit/opensubtitles.py index 7efc74e..0c8bfce 100644 --- a/scrapeit/opensubtitles.py +++ b/scrapeit/opensubtitles.py @@ -69,10 +69,12 @@ def downloadSubtitleByID(opensubtitle_id): data = read_url('http://www.opensubtitles.org/en/subtitles/%s' % opensubtitle_id) soup = BeautifulSoup(data) srts = {} + c = 0 for a in soup('a', {'href': re.compile('download/file')}): download_url = 'http://www.opensubtitles.org' + a['href'] file_name = a.contents[-1].split('\n')[0].strip() data = loadSrtUnicode(read_url(download_url)) if data: - srts[file_name] = data + srts["%03d_%s" %(c, file_name)] = data + c += 1 return srts