From bf7aeb07da51dc0c8616308a5c7616826e58b002 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Wed, 11 May 2011 16:40:53 -0500 Subject: [PATCH] imdb: ignore unknown fields. PEP8 rottentomatoes --- plugins/imdb.py | 10 +++++++--- plugins/rottentomatoes.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/imdb.py b/plugins/imdb.py index 53a8fe2..83e96e2 100644 --- a/plugins/imdb.py +++ b/plugins/imdb.py @@ -14,8 +14,12 @@ def imdb(inp): elif content['Response'] == 'True': content['URL'] = 'http://www.imdb.com/title/%(ID)s' % content - return "\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s " \ - "\x02%(Runtime)s\x02. \x02%(Rating)s/10\x02 with " \ - "\x02%(Votes)s\x02 votes. %(URL)s" % content + out = '\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s' + if content['Runtime'] != 'N/A': + out += ' \x02%(Runtime)s\x02.' + if content['Rating'] != 'N/A' and content['Votes'] != 'N/A': + out += ' \x02%(Rating)s/10\x02 with \x02%(Votes)s\x02 votes.' + out += ' %(URL)s' + return out % content else: return 'unknown error' diff --git a/plugins/rottentomatoes.py b/plugins/rottentomatoes.py index 5e20c43..bbac607 100644 --- a/plugins/rottentomatoes.py +++ b/plugins/rottentomatoes.py @@ -7,6 +7,7 @@ movie_reviews_url = api_root+'movies/%s/reviews.json?apikey=%s&review_type=all' response = u"%s - critics: \x02%d%%\x02 (%d\u2191%d\u2193) audience: \x02%d%%\x02 - %s" + @hook.command('rt') def rottentomatoes(inp, bot=None): '.rt -- gets ratings for <title> from Rotten Tomatoes' @@ -33,4 +34,4 @@ def rottentomatoes(inp, bot=None): fresh = critics_score * review_count / 100 rotten = review_count - fresh - return response % (title, critics_score, fresh, rotten, audience_score, url) \ No newline at end of file + return response % (title, critics_score, fresh, rotten, audience_score, url)