From 209e754d351eba4abd914d6bf155285e1895b2f7 Mon Sep 17 00:00:00 2001 From: Rolux Date: Wed, 7 May 2008 14:33:00 +0200 Subject: [PATCH] fixing a bug in itunes.py --- ox/itunes.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ox/itunes.py b/ox/itunes.py index b758685..b5bb572 100644 --- a/ox/itunes.py +++ b/ox/itunes.py @@ -88,14 +88,17 @@ def parseCast(xml, title): def parseMovies(xml, title): list = [] - strings = findRe(xml, '%s(.*?)' % title[:-1].upper()).split('') - strings.pop() - for string in strings: - list.append({ - 'id': findRe(string, 'viewMovie\?id=(.*?)&'), - 'title': findRe(string, '(.*?)') - }) - return list + try: + strings = findRe(xml, '%s(.*?)' % title[:-1].upper()).split('') + strings.pop() + for string in strings: + list.append({ + 'id': findRe(string, 'viewMovie\?id=(.*?)&'), + 'title': findRe(string, '(.*?)') + }) + return list + except: + return list class ItunesAlbum: def __init__(self, id = '', title = '', artist = ''): @@ -176,4 +179,5 @@ if __name__ == '__main__': for v in data['relatedMovies']: data = ItunesMovie(id = v['id']).getData() print simplejson.dumps(data, sort_keys = True, indent = 4) - # print test.getData() \ No newline at end of file + data = ItunesMovie(id='272960052').getData() + print simplejson.dumps(data, sort_keys = True, indent = 4)